From: Alexander Potapenko <glider@google.com>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
syzbot <syzbot+3f29ca2efb056a761e38@syzkaller.appspotmail.com>,
clang-built-linux <clang-built-linux@googlegroups.com>,
Borislav Petkov <bp@alien8.de>, "H. Peter Anvin" <hpa@zytor.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
KVM list <kvm@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@redhat.com>,
syzkaller-bugs <syzkaller-bugs@googlegroups.com>,
Thomas Gleixner <tglx@linutronix.de>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
"the arch/x86 maintainers" <x86@kernel.org>,
Sean Christopherson <sean.j.christopherson@intel.com>
Subject: Re: BUG: unable to handle kernel NULL pointer dereference in handle_external_interrupt_irqoff
Date: Mon, 23 Mar 2020 18:55:07 +0100 [thread overview]
Message-ID: <CAG_fn=WE0BmuHSxUoBJWQ9dnZ4X5ZpBqcT9rQaDE_6HAfTYKQA@mail.gmail.com> (raw)
In-Reply-To: <CAKwvOdkXi1MN2Yqqoa6ghw14tQ25WYgyJkSv35-+1KRb=cmhZw@mail.gmail.com>
I've reduced the faulty test case to the following code:
=================================
a;
long b;
register unsigned long current_stack_pointer asm("rsp");
handle_external_interrupt_irqoff() {
asm("and $0xfffffffffffffff0, %%rsp\n\tpush $%c[ss]\n\tpush "
"%[sp]\n\tpushf\n\tpushq $%c[cs]\n\tcall *%[thunk_target]\n"
: [ sp ] "=&r"(b), "+r" (current_stack_pointer)
: [ thunk_target ] "rm"(a), [ ss ] "i"(3 * 8), [ cs ] "i"(2 * 8) );
}
=================================
(in fact creduce even throws away current_stack_pointer, but we
probably want to keep it to prove the point).
Clang generates the following code for it:
$ clang vmx.i -O2 -c -w -o vmx.o
$ objdump -d vmx.o
...
0000000000000000 <handle_external_interrupt_irqoff>:
0: 8b 05 00 00 00 00 mov 0x0(%rip),%eax # 6
<handle_external_interrupt_irqoff+0x6>
6: 89 44 24 fc mov %eax,-0x4(%rsp)
a: 48 83 e4 f0 and $0xfffffffffffffff0,%rsp
e: 6a 18 pushq $0x18
10: 50 push %rax
11: 9c pushfq
12: 6a 10 pushq $0x10
14: ff 54 24 fc callq *-0x4(%rsp)
18: 48 89 05 00 00 00 00 mov %rax,0x0(%rip) # 1f
<handle_external_interrupt_irqoff+0x1f>
1f: c3 retq
The question is whether using current_stack_pointer as an output is
actually a valid way to tell the compiler it should not clobber RSP.
Intuitively it is, but explicitly adding RSP to the clobber list
sounds a bit more bulletproof.
next prev parent reply other threads:[~2020-03-23 17:55 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-22 6:43 BUG: unable to handle kernel NULL pointer dereference in handle_external_interrupt_irqoff syzbot
2020-03-22 6:59 ` Dmitry Vyukov
2020-03-22 7:03 ` Dmitry Vyukov
2020-03-23 8:18 ` Paolo Bonzini
2020-03-23 16:31 ` Alexander Potapenko
2020-03-23 16:39 ` Sean Christopherson
2020-03-23 16:43 ` Alexander Potapenko
2020-03-23 16:57 ` Nick Desaulniers
2020-03-23 17:28 ` Nick Desaulniers
2020-03-23 17:55 ` Alexander Potapenko [this message]
2020-03-23 18:06 ` Nick Desaulniers
2020-03-23 18:06 ` Alexander Potapenko
2020-03-23 18:16 ` Nick Desaulniers
2020-03-23 18:49 ` Nick Desaulniers
2020-03-23 19:12 ` [PATCH] KVM: VMX: don't allow memory operands for inline asm that modifies SP Nick Desaulniers
2020-03-23 19:30 ` BUG: unable to handle kernel NULL pointer dereference in handle_external_interrupt_irqoff Nick Desaulniers
2020-03-23 19:39 ` Paolo Bonzini
2020-03-22 8:53 ` syzbot
2020-03-22 13:29 ` syzbot
2020-03-22 13:43 ` Dmitry Vyukov
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='CAG_fn=WE0BmuHSxUoBJWQ9dnZ4X5ZpBqcT9rQaDE_6HAfTYKQA@mail.gmail.com' \
--to=glider@google.com \
--cc=bp@alien8.de \
--cc=clang-built-linux@googlegroups.com \
--cc=dvyukov@google.com \
--cc=hpa@zytor.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=ndesaulniers@google.com \
--cc=pbonzini@redhat.com \
--cc=sean.j.christopherson@intel.com \
--cc=syzbot+3f29ca2efb056a761e38@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--cc=x86@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;
as well as URLs for NNTP newsgroup(s).