From: Carl Spalletta <cspalletta@yahoo.com>
To: linux-kernel@vger.kernel.org
Subject: Cute kernel trick, or communistic ploy?
Date: Fri, 30 May 2003 16:12:31 -0700 (PDT) [thread overview]
Message-ID: <20030530231231.64427.qmail@web41501.mail.yahoo.com> (raw)
Output of program to simulate a /proc file in a stopped kernel,
using the same kernel function(s) used to generate the actual file
when the kernel is up:
(gdb) source ./proc-uptime
$3 = (void *) 0xa1aec000
$4 = (void *) 0xa1da48d4
$5 = (void *) 0xa1da4384
$6 = (void *) 0xa1da48ac
$7 = 0
"remember to 'call(kfree($page))' when finished
"4080219633.89 395.85
(gdb)
This program works fine in the um arch but I was wondering what
the pitfalls are in an approach like this. This is a trivial example,
but other /proc files do very complicated bookkeeping and formatting;
and this method should be equally applicable to those.
GDB program 'proc-uptime' (18 lines):
set $gfp_atomic=0x20
call(kmalloc(4096,$gfp_atomic))
set $page=$
call(kmalloc(32,$gfp_atomic))
set $zero=(int *)$
set *$zero=(int)0
call(kmalloc(32,$gfp_atomic))
set $start=(int **)$
set *$start=$zero
call(kmalloc(32,$gfp_atomic))
set $eof=(int *)$
set *$eof=1
call(uptime_read_proc((char *)$page,(char **)$start,(off_t)0,\
0,$eof,(void *)$zero))
call(kfree($zero))
call(kfree($eof))
call(kfree($start))
echo "remember to 'call(kfree($page))' before continuing\n"
printf "%s\n",$page
next reply other threads:[~2003-05-30 22:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-30 23:12 Carl Spalletta [this message]
2003-05-31 1:33 ` Werner Almesberger
2003-05-31 3:57 ` Werner Almesberger
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=20030530231231.64427.qmail@web41501.mail.yahoo.com \
--to=cspalletta@yahoo.com \
--cc=linux-kernel@vger.kernel.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®