From: "Rusty Lynch" <rusty@linux.co.intel.com>
To: <vamsi@in.ibm.com>
Cc: <rusty@rustcorp.com.au>, "lkml" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] kprobes for 2.5.47
Date: Tue, 12 Nov 2002 17:58:39 -0800 [thread overview]
Message-ID: <004b01c28ab8$2f89a2c0$77d40a0a@amr.corp.intel.com> (raw)
In-Reply-To: <20021112165053.A1342@in.ibm.com>
When register_kprobe() is called with a bad addr, we crash the kernel.
Should it be the reponsibility of the caller, or the kernel to make sure the
addr is ok?
The kernel could check by adding a
+unsigned short tmp;
....
+if(__get_user(tmp, (unsigned short *)p->addr)) {
+ ret = -EINVAL;
+ goto out;
+}
to register_kprobe()
> +int register_kprobe(struct kprobe *p)
> +{
> + int ret = 0;
> +
> + spin_lock_irq(&kprobe_lock);
> + if (get_kprobe(p->addr)) {
> + ret = -EEXIST;
> + goto out;
> + }
> + list_add(&p->list, &kprobe_table[hash_ptr(p->addr, KPROBE_HASH_BITS)]);
> +
> + p->opcode = *p->addr;
> + *p->addr = BREAKPOINT_INSTRUCTION;
> + flush_icache_range(p->addr, p->addr + sizeof(kprobe_opcode_t));
> + out:
> + spin_unlock_irq(&kprobe_lock);
> + return ret;
> +}
BTW, I have a stupid little sample char driver that reads in address/message
pairs and then adds a probe that printk's the message at the address. This
was just my way of learning how to use kprobes. Should I post it? I would
love to get feedback on what I did wrong, but I hate to spam the list.
-rustyl
next prev parent reply other threads:[~2002-11-13 1:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-12 11:20 Vamsi Krishna S .
2002-11-13 1:58 ` Rusty Lynch [this message]
2002-11-13 3:08 ` Randy.Dunlap
2002-11-13 4:15 ` Rusty Lynch
2002-11-13 7:22 ` Vamsi Krishna S .
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='004b01c28ab8$2f89a2c0$77d40a0a@amr.corp.intel.com' \
--to=rusty@linux.co.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=vamsi@in.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome