From: "chengjian (D)" <cj.chengjian@huawei.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: <tglx@linutronix.de>, <mingo@redhat.com>, <dvhart@infradead.org>,
<linux-kernel@vger.kernel.org>, <xiexiuqi@huawei.com>,
<huawei.libin@huawei.com>, <dvhart@infradead.org>
Subject: Re: [PATCH] futex: use fault_in to avoid infinite loop
Date: Fri, 8 Dec 2017 20:42:28 +0800 [thread overview]
Message-ID: <f2828b10-43a3-5ce4-6e8e-e0464edb409b@huawei.com> (raw)
In-Reply-To: <20171206214007.GI3857@worktop>
On 2017/12/7 5:40, Peter Zijlstra wrote:
> @@ -3262,6 +3262,8 @@ static int futex_wait_requeue_pi(u32 __user
> *uaddr, unsigned int flags,
> SYSCALL_DEFINE2(set_robust_list, struct robust_list_head __user *, head,
> size_t, len)
> {
> + unsigned long address = (unsigned long)head;
> +
> if (!futex_cmpxchg_enabled)
> return -ENOSYS;
> /*
> @@ -3270,6 +3272,9 @@ SYSCALL_DEFINE2(set_robust_list, struct robust_list_head __user *, head,
> if (unlikely(len != sizeof(*head)))
> return -EINVAL;
>
> + if (unlikely(address % __alignof__(*head)))
> + return -EMORON;
> +
Yeah, This looks nicer. It solved the problem fundamentally
Also for other architecture, such as arm32 which will also
cause a crash without this PATCH.
If we incoming a misaligned address from user space,
the system call will return directly with a new errno(EMORON).
BUT
int handle_futex_death(u32 __user *uaddr, struct task_struct *curr, int pi)
{
retry:
//......
/* return -EFAULT */
if (cmpxchg_futex_value_locked (& nval, uaddr, uval, mval)) {
/* always return 0 */
if (fault_in_user_writeable(uaddr))
return -1; /* never here */
goto retry; /* then goto retry */
//......
}
Does it correct here?
if we get other exception here next time, does kernel push himself into
a new infinite loop ?
Thanks.
CHENG Jian
next prev parent reply other threads:[~2017-12-08 12:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-06 14:21 Cheng Jian
2017-12-06 16:04 ` Peter Zijlstra
2017-12-06 21:40 ` Peter Zijlstra
2017-12-08 5:21 ` Darren Hart
2017-12-08 10:50 ` Peter Zijlstra
2017-12-08 12:42 ` chengjian (D) [this message]
2017-12-28 14:21 ` [tip:locking/urgent] futex: Sanitize user address in set_robust_list() tip-bot for Peter Zijlstra
2017-12-30 7:40 ` [PATCH] futex: use fault_in to avoid infinite loop Michael Kerrisk
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=f2828b10-43a3-5ce4-6e8e-e0464edb409b@huawei.com \
--to=cj.chengjian@huawei.com \
--cc=dvhart@infradead.org \
--cc=huawei.libin@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=xiexiuqi@huawei.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
all inboxes | Powered by JetHome®