Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp850447pxa; Wed, 19 Aug 2020 17:15:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcTcEDyMXcWo9gWBJW9uBzmzL1SNOaGbgR8gkDpYkhmAG+s2j99vLTKsU5SjWMgwJGqtJ9 X-Received: by 2002:a05:6402:847:: with SMTP id b7mr538605edz.39.1597882529100; Wed, 19 Aug 2020 17:15:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597882529; cv=none; d=google.com; s=arc-20160816; b=LUPKOoKcj2YWdqTw5kwD0q59FTRflkDElOlCv5Pxc4LfvL3WLT+lvSVvuuhXCLv2Xy RUiXtuhY0xKRyCgiNUVx2CbZtqiBBOBKJ+SIVX0lKeI4i/Br6b8nvjze5kTDw4kfw6AP XQZUNbc3zEz9fiCbLU7lMvLSlLB1I1mvmNFtdtuytOg2JGumTaIgPWyLezQWfWeRbEXC G+AiOodF+t8XCFu6H6tU+7s2EmFeC37Q+zIvI7+HJSgB1+BV3yMS6j5B9Lt/27OB6T+y h2WoiafC51YJDTbCx3hvsu+hzB9gMlLyQ/SqyihplGjMj3sKSHReaiJX6ItQYp0gi733 neaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=prpysaLSpsQPInpk6icYOqKxMa5w7mRyO3MX0muXpwM=; b=aHRrA14PgBFmxv30naFv6gxXBisx13pyvnAjcdFrFI9B71QHfF+3eIm4kB3xCLLlJO IyDx2cMwPL1ZLYBQoGxlMjX3mrq/qSSvHGnw0BCT7S2UNsi9ZAl3SSkW84AdpZUjSfyV JvdsC5l3y+DAk95z+Arq+9E6uloLmM+dS+vpNMBzDtwXztsmDkS9xdyB52uqJasf9fWG KmxuVe6y0egxqePJ90X3qU1qGwrVvhE5Fji4rIIWd0qRJegL8iZtP17N5XeKcbeLT05D dLVx93ZkNjTQeNl38h3rS85tiYC68GC3SYXwDJTymyXQ0FQvFQcqxHUcme9/i6qg1Hy9 OqTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Yue7lrmo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q5si156109ejy.403.2020.08.19.17.15.05; Wed, 19 Aug 2020 17:15:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Yue7lrmo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726995AbgHTAOg (ORCPT + 99 others); Wed, 19 Aug 2020 20:14:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:44220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727817AbgHTAOb (ORCPT ); Wed, 19 Aug 2020 20:14:31 -0400 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CD88E22B45 for ; Thu, 20 Aug 2020 00:14:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597882471; bh=ErsxOzudaYAqd/JOMw1cblnI0Jw1+r4C15tCDSy35Mw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Yue7lrmosAlgj8CCubCKwjR2GdG5sCA0nA5lNCxkUmFszRG/XaSYaQzp66SO/kx+W LQaMf9wycov2ECJiIx4pMyrFANfDjqS0W1xt78gIsh2R7wO+Us6bgXznij9+I5fH4I MZiu7ZmnePaj0OUmph3xa8JkAq21mbrxrMLttbik= Received: by mail-wm1-f42.google.com with SMTP id g75so103843wme.4 for ; Wed, 19 Aug 2020 17:14:30 -0700 (PDT) X-Gm-Message-State: AOAM533vTE1GQmbQwg4Efqv0R8GNkoxM7zvHX6s+jL5plSq21Mr+axWd NoihyPrDh8LX+znEuHFf1fSVLpiPnil9y4ONrAX20A== X-Received: by 2002:a1c:4c17:: with SMTP id z23mr757787wmf.49.1597882469268; Wed, 19 Aug 2020 17:14:29 -0700 (PDT) MIME-Version: 1.0 References: <20200819184149.GH2674@hirez.programming.kicks-ass.net> <20200819213534.GQ3982@worktop.programming.kicks-ass.net> <20200819224731.3edo5lqw6lbuprdx@treble> In-Reply-To: <20200819224731.3edo5lqw6lbuprdx@treble> From: Andy Lutomirski Date: Wed, 19 Aug 2020 17:14:18 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [REGRESSION 5.8] x86/entry: DR0 break-on-write not working To: Josh Poimboeuf Cc: Peter Zijlstra , Kyle Huey , Thomas Gleixner , Alexandre Chartre , Andy Lutomirski , "Robert O'Callahan" , LKML , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "Paul E. McKenney" , Frederic Weisbecker , Paolo Bonzini , Sean Christopherson , Masami Hiramatsu , Petr Mladek , Steven Rostedt , Joel Fernandes , Boris Ostrovsky , Juergen Gross , Brian Gerst , Mathieu Desnoyers , Will Deacon Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 19, 2020 at 3:47 PM Josh Poimboeuf wrote: > > On Wed, Aug 19, 2020 at 11:35:34PM +0200, Peter Zijlstra wrote: > > On Wed, Aug 19, 2020 at 12:28:16PM -0700, Kyle Huey wrote: > > > > > > I'm guess that is not the expected outcome, is that the same failure you > > > > saw? > > > > > > Yes. Is status also 0x4d00 for you? > > > > Indeed. > > > > > The program is expected to complete with no assertions firing. > > > > When I comment out the break-on-exec test, the break-on-write test > > succeeds. > > > > When I add a few printk()'s to our #DB handler (6) the program will > > magically work again. > > I added some trace_printk()'s and I think the #DB handler is calling > schedule???? > > exc_debug_user() > irqentry_exit_to_user_mode() > exit_to_user_mode_prepare() > exit_to_user_mode_loop() > schedule() > > So #DB schedules out, then the process scheduls in and tells ptrace to > set the data breakpoint in DR7. Then the #DB handler schedules back in > and overwrites DR7 with the original value. > > What amazes me is that it successfully schedules back to the end of the > #DB handler finish and everything keeps working. > > Do we not have assertions in the scheduler to catch this? You almost nailed it. I'm pretty sure you have the buggy sequence of events right, but for the wrong reason. There's nothing wrong with scheduling when delivering SIGTRAP, but it's definitely wrong to blindly save and restore DR7 around scheduling and around ptrace invocations. Remember this is an entry from user mode, so it runs on the user stack. Patch coming. --Andy