From: Ingo Molnar <mingo@elte.hu>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jan Kiszka <jan.kiszka@web.de>, Ray Lee <ray-lk@madrabbit.org>,
Sam Ravnborg <sam@ravnborg.org>,
linux-kernel@vger.kernel.org, Andrew Morton <akpm@zip.com.au>,
Thomas Gleixner <tglx@linutronix.de>,
Jason Wessel <jason.wessel@windriver.com>
Subject: Re: [git pull] kgdb light, v5
Date: Sun, 10 Feb 2008 21:19:04 +0100 [thread overview]
Message-ID: <20080210201904.GB24677@elte.hu> (raw)
In-Reply-To: <alpine.LFD.1.00.0802101134470.2896@woody.linux-foundation.org>
* Linus Torvalds <torvalds@linux-foundation.org> wrote:
> > +static int kgdb_get_mem(char *addr, unsigned char *buf, int count)
> > {
> > + if ((unsigned long)addr < TASK_SIZE)
> > + return -EFAULT;
> >
> > + return probe_kernel_read(buf, addr, count);
>
> Ok, so this is a pretty function after all the cleanups, but I
> actually don't think that "if ((unsigned long)addr < TASK_SIZE)" is
> really even asked for.
>
> Why not let kgdb look at user memory? I'd argue that in a lot of
> cases, it might be quite nice to do, to see what user arguments in
> memory are etc etc (think things like futexes, where user memory
> contents really do matter).
yes. We should allow kgdb to look at just about anything that can be
done safely - and we've got all the necessary protections against
pagefaults via pagefault_disable().
> So I'd suggest getting rid of the whole "kgdb_{get|set}_mem()"
> functions, and just using "probe_kernel_{read|write}()" directly
> instead.
>
> (Not that I necessarily love those names either, but whatever..)
>
> The TASK_SIZE checks make more sense in kgdb_validate_break_address()
> and friends, where it actually does make sense to check that it's
> really a *kernel* address.
>
> But even there, I'm not sure if the right check is to compare against
> TASK_SIZE, since kernel and user memory addresses can in theory be
> distinct (that's why we have "set_fs()" historically, and while it's
> no longer true on x86 and hasn't been in a long time, the kernel
> conceptually allows it - see my previous reply about that whole
> get_fs/set_fs thing in the definition of probe_kernel_read/write).
hm, is access_ok() safe on all architectures from irq context? That's
the cross-arch equivalent of TASK_SIZE checks normally.
> > + if (count == 2 && ((long)mem & 1) == 0)
> > + err = probe_kernel_read(tmp, mem, 2);
> > + else if (count == 4 && ((long)mem & 3) == 0)
> > + err = probe_kernel_read(tmp, mem, 4);
> > + else if (count == 8 && ((long)mem & 7) == 0)
> > + err = probe_kernel_read(tmp, mem, 8);
> > + else
> > + err = probe_kernel_read(tmp, mem, count);
>
> There's absolutely no reason to care about the alignment, since if you
> now use "probe_kernel_read()", the sane thing to do is to just do
>
> err = probe_kernel_read(tmp, mem, count);
> if (!err) {
> while (count > 0) {
> buf = pack_hex_byte(buf, *tmp);
> tmp++;
> count--;
> }
>
> and you're all done. No?
yes, the full function now looks like this:
int kgdb_mem2hex(char *mem, char *buf, int count)
{
char *tmp;
int err;
/*
* We use the upper half of buf as an intermediate buffer for the
* raw memory copy. Hex conversion will work against this one.
*/
tmp = buf + count;
err = probe_kernel_read(tmp, mem, count);
if (!err) {
while (count > 0) {
buf = pack_hex_byte(buf, *tmp);
tmp++;
count--;
}
*buf = 0;
}
return err;
}
i'll test this a bit.
Ingo
next prev parent reply other threads:[~2008-02-10 20:19 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-10 7:13 [0/6] kgdb light Ingo Molnar
2008-02-10 7:37 ` David Miller
2008-02-10 10:47 ` Sam Ravnborg
2008-02-10 13:25 ` Jan Kiszka
2008-02-10 19:31 ` Sam Ravnborg
2008-02-10 20:23 ` Jan Kiszka
2008-02-10 21:16 ` Ingo Molnar
2008-02-10 21:30 ` Sam Ravnborg
2008-02-10 21:34 ` Ingo Molnar
2008-02-10 16:36 ` [git pull] kgdb light, v5 Ingo Molnar
2008-02-10 17:30 ` Ray Lee
2008-02-10 17:39 ` Jan Kiszka
2008-02-10 18:59 ` Ray Lee
2008-02-10 18:53 ` Jan Kiszka
2008-02-10 19:34 ` Ingo Molnar
2008-02-10 19:44 ` Linus Torvalds
2008-02-10 20:19 ` Ingo Molnar [this message]
2008-02-10 20:22 ` Jan Kiszka
2008-02-10 21:13 ` Ingo Molnar
2008-02-10 20:29 ` Ingo Molnar
2008-02-10 20:41 ` Ingo Molnar
2008-02-10 19:34 ` Sam Ravnborg
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=20080210201904.GB24677@elte.hu \
--to=mingo@elte.hu \
--cc=akpm@zip.com.au \
--cc=jan.kiszka@web.de \
--cc=jason.wessel@windriver.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ray-lk@madrabbit.org \
--cc=sam@ravnborg.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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
all inboxes | Powered by JetHome®