From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932662AbbI1KXU (ORCPT ); Mon, 28 Sep 2015 06:23:20 -0400 Received: from mail.skyhub.de ([78.46.96.112]:49303 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932447AbbI1KXR (ORCPT ); Mon, 28 Sep 2015 06:23:17 -0400 Date: Mon, 28 Sep 2015 12:23:14 +0200 From: Borislav Petkov To: Dmitry Vyukov Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , luto@kernel.org, dvlasenk@redhat.com, "x86@kernel.org" , LKML , Kostya Serebryany , Alexander Potapenko , Andrey Konovalov , Andrey Ryabinin , Sasha Levin , Andi Kleen , kasan-dev Subject: Re: [PATCH] arch/x86: fix out-of-bounds in get_wchan() Message-ID: <20150928102314.GB3556@pd.tnic> References: <1443430839-13225-1-git-send-email-dvyukov@google.com> <20150928093741.GA3556@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 28, 2015 at 11:49:18AM +0200, Dmitry Vyukov wrote: > Original code did: > > if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE) > return 0; > fp = *(u64 *)(p->thread.sp); > > p->thread.sp can change concurrently. > So we could check that p->thread.sp is within stack bounds, but then > dereference another value (which is already outside of bounds). Right, we do deref it. I realized that after hitting "Send" :\ Which begs another, probably also stupid, question: What guarantees the task won't disappear after we've checked p? I.e., after this: if (!p || p == current || p->state == TASK_RUNNING) return 0; Thanks. -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply.