From: Carmelo Amoroso <carmelo73@gmail.com>
To: linux-sh@vger.kernel.org
Subject: Cache coherency problem in do_execve while passing arguments
Date: Thu, 27 Dec 2007 17:12:50 +0000 [thread overview]
Message-ID: <4773DD12.9000001@gmail.com> (raw)
Hi Paul,
a customer of us (STLinux) found a problem running a simple
testcase.
The test simply runs forever in a loop doing modprobe and rmmod
on a dummy kernel module.
After a few loops, it failed because the module arguments passed were corrupted.
In this case, both modprobe and rmmod are symlinks to busybox.
In particular, modprobe (bb), to insert module use the execvp libc
call to execute insmod (it doesn't care if insmod is bb or not).
The problem is due to the fact that into do_execve in kernel 2.6.23.1
the page used for arguments is not flashed from cache in memory
being flush_kernel_dcache_page a NOP.
This is an extract of the do_execve code flow
do_execve flow for argument setup: kernel 2.6.23.1 (STLinux2.3)
do_execve
|---> copy_strings(argc, argv, bprm)
| |---> page = get_arg_page()
| | |---> get_user_pages(&page)
| | |---> return page
| |---> kmapped_page = page
| |---> flush_kernel_dcache_page(kmapped_page) /* THIS IS CURRENTLY a NOP */
|
|---> search_binary_handler
|---> load_elf_binary
|---> setup_arg_page(bprm,...)
|---> current->mm->arg_start = bprm->p
|---> expand_stack
While in previous kernel the test passed. Indeed, looking at the old code
do_execve flow for argument setup: kernel 2.6.17 (STLinux2.2)
do_execve
|---> copy_strings(argc, argv, bprm)
|---> search_binary_handler
|---> load_elf_binary
|---> setup_arg_page(bprm,...)
|---> current->mm->arg_start = bprm->p
|---> install_arg_page(page)
|---> flush_dcache_page(page) /* THIS DO THE TRICK */
As you can see, in the old code flush_dcache_page was explicitly called, while in never kernel
isn't.
The following patch into cacheflush.h solves the problem and the test ran for 2 days without problem
I'm not sure if this fix should be applied to the common header include/asm-sh/cacheflush.h (being valid for all
sh subarch) or to the sh4 specific one include/asm-sh/cpu-sh4/cacheflush.h
+#define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE
+static inline void flush_kernel_dcache_page(struct page *page)
+{
+ flush_dcache_page(page);
+}
+
Your comments are welcome
Happy new year
Carmelo
next reply other threads:[~2007-12-27 17:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-27 17:12 Carmelo Amoroso [this message]
2007-12-27 22:24 ` Cache coherency problem in do_execve while passing arguments Paul Mundt
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=4773DD12.9000001@gmail.com \
--to=carmelo73@gmail.com \
--cc=linux-sh@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