From: Martin Schwidefsky <schwidefsky@de.ibm.com>
To: linux-kernel@vger.kernel.org,
Alexander Viro <viro@zeniv.linux.org.uk>,
Linus Torvalds <torvalds@linux-foundation.org>
Cc: Carsten Otte <cotte@de.ibm.com>
Subject: Using TASK_SIZE for kernel threads
Date: Fri, 24 Feb 2017 17:15:28 +0100 [thread overview]
Message-ID: <20170224161529.80054-1-schwidefsky@de.ibm.com> (raw)
Hello,
this week we had some fun with kernel 4.10 on s390. Carsten found that
the kernel kept crashing reproducibly on his system. Not on mine or any
other system, just his.
The kdevtmpfs kernel thread crashed in __queued_work as it tried to
terminate. The devtmpfsd function got an error on the sys_mount() call.
Why it crashes on termination is a different story, the interesing part
is why sys_mount() got an error.
After some more debugging Carsten found out that copy_mount_options()
only got 2 bytes of the option string, "mo" instead of "mode=0755".
It turned out that the s390 definition of TASK_SIZE together with the
size calculation in copy_mount_options causes this:
#define TASK_SIZE_OF(tsk) ((tsk)->mm->context.asce_limit)
and
size = TASK_SIZE - (unsigned long)data;
For a kernel thread (tsk)->mm is zero and the value located at
(0)->context.asce_limit happened to be close enough to the data
pointer that the 'size' result is a small number, in this case 2.
Now I fixed this in the s390 code, the patch is queued and will be
included in next weeks please-pull. But I am wondering about the use
of TASK_SIZE in kernel threads. For x86 copy_mount_options works
because the size calculation will give a negative result for 'data'
pointing to kernel space. Which is corrected by the size limit:
if (size > PAGE_SIZE)
size = PAGE_SIZE;
Wouldn't it be cleaner to test "get_fs()==KERNEL_DS" and just use
size=4096 in this case? The detour via TASK_SIZE does not make much
sense to me.
To find out how big the problem is, I have added a warning to TASK_SIZE
to create a console messsage if it is called for a task without an mm.
The only hit has been copy_mount_options.
For reference I have included the s390 patch.
Martin Schwidefsky (1):
s390: TASK_SIZE for kernel threads
arch/s390/include/asm/processor.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--
2.7.4
next reply other threads:[~2017-02-24 16:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-24 16:15 Martin Schwidefsky [this message]
2017-02-24 16:15 ` [PATCH] s390: " Martin Schwidefsky
2017-02-25 18:19 ` Using " Linus Torvalds
2017-02-27 6:21 ` Martin Schwidefsky
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=20170224161529.80054-1-schwidefsky@de.ibm.com \
--to=schwidefsky@de.ibm.com \
--cc=cotte@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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®