Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp676476pxa; Wed, 19 Aug 2020 11:44:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzn4jDe0GmxzBmeW96mebZS/yAcBIhVVZz0RyRhlLlHBwyLrWQYcLadSlKcaPSuuiZqMc23 X-Received: by 2002:a05:6402:1c85:: with SMTP id cy5mr26536678edb.6.1597862641954; Wed, 19 Aug 2020 11:44:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597862641; cv=none; d=google.com; s=arc-20160816; b=LaFAsJjBUMN1ubKRBBtIujM+qcuLt+nOE8cFEhEcmmTLFIML+jksXDQrJw73eQG9vH unsmOq5hxT9onoPOUSXaUgqseosEZL81x1y8D2bzdNA/D+FWJiam7dhzCFflh/jPDmmQ EviwNOHQ0fwTXh1nsrLk2ccb5C6kNJ9aCIt79A4hkOg9nogFN+DiHhszQ0IBb05za93t LNtXA2LvdpKod/No+kQZzcrLKI69A3u73U4w3yvk0tXsLE3NpiDrwhUPQz4IZprGZkDK kcDbZgxLu7FtHehMcFN8+/PC29L2mMoaK2g28MDjbIsfOCAFWZVgiDr/0zdTzRXTzKU/ wKEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=B29FoEhgmnRdMUe2XUeYcC87nlcEZTTxdQ1pYpiIYXc=; b=Ey0UZvRBV35zGfZYZkYdP7S7/F9A5nDfcz/wrJh/qrstnKrMhJyRHUIuvBQykbiTVe lEkPgpCVD/ZlUsSqmXPM1bY/H3kzA1r/Hlhv6/CbAUeyd6/B4dY4FwZ0ZVoe9V3YYLRR grClxxwNBGcPdJZH0BpJ+WyA7Dp2cDqWXRTNs69S+G3sUwEno9lPbTQFvDyBYAiOsxk+ pJ6TOiIHJtgDbNNaxL1nhr4r+vfREIi3bu2dQ8doU/ChRD5oo5F1t6YEHrbQGqb/Iheg +ZX+XU7b1hZ23cKVbrbywNN1UexNVXKfF50QkcXJSqMQCkCUSTrChC+MswlpSxpFP1w0 j4KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=ioqTZ1gW; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lc20si15933871ejb.468.2020.08.19.11.43.38; Wed, 19 Aug 2020 11:44:01 -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=fail header.i=@infradead.org header.s=casper.20170209 header.b=ioqTZ1gW; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726786AbgHSSmi (ORCPT + 99 others); Wed, 19 Aug 2020 14:42:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726772AbgHSSmg (ORCPT ); Wed, 19 Aug 2020 14:42:36 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46569C061757 for ; Wed, 19 Aug 2020 11:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=B29FoEhgmnRdMUe2XUeYcC87nlcEZTTxdQ1pYpiIYXc=; b=ioqTZ1gWxjszNRk3mHLVrPtu0Q v70912J1b30aGRHW6W6fI+R0tQmYy1omfZLPp1l543GOAIwARpCYRW/z9BAth+4I2R+MU6YyPA555 1018n8TTvy+yUKT/VP9L6NPFlvhEZ1WCObL0u6Odv3SCmnOHp3Mo1eonp5QPha5hwc7tft5MCdCbT UUYd2Cn6s3iZVnLDsbv14OubA/jqUUMwYp4A/yRWao+b9c6OdKmzm4o0sghhB/WaU4PmRXX3ktQyz Owq7+5/Tp+jpo2M4T8rWvKws5tAHSkDUEjuAF9cgcvUUazDqUbgcD+3aXfPIniGUkF1ojf7w4dqFz aFqm8evg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8T21-0005z2-Ey; Wed, 19 Aug 2020 18:41:53 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 33437301179; Wed, 19 Aug 2020 20:41:50 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 012A12BFF9E50; Wed, 19 Aug 2020 20:41:49 +0200 (CEST) Date: Wed, 19 Aug 2020 20:41:49 +0200 From: peterz@infradead.org To: Kyle Huey Cc: 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 , Josh Poimboeuf , Will Deacon Subject: Re: [REGRESSION 5.8] x86/entry: DR0 break-on-write not working Message-ID: <20200819184149.GH2674@hirez.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 10:53:58AM -0700, Kyle Huey wrote: > rr, a userspace record and replay debugger[0], has a test suite that > attempts to exercise strange corners of the Linux API. One such > test[1] began failing after 2bbc68f8373c0631ebf137f376fbea00e8086be7. > I have not tried to understand what has changed in the kernel here but > since the commit message says "No functional change" I assume > something has gone wrong. > > The test expects to get a SIGTRAP when watchvar is written to in the > forked child, but instead the program just exits normally and we get a > status value corresponding to that (exit code 77 = wait status > 0x4d00). This test program should be usable outside of rr's test suite > if you replace the test_assert/atomic_puts functions with > assert/printf and replace the util.h include with appropriate standard > includes. > > This regression is present in 5.8. $ uname -a Linux ivb-ep 5.9.0-rc1-dirty #343 SMP PREEMPT Wed Aug 19 15:04:35 CEST 2020 x86_64 GNU/Linux $ ./ptrace_debug_regs FAILED: errno=0 (Success) ptrace_debug_regs: ptrace_debug_regs.c:104: main: Assertion `"FAILED: !" && check_cond(status == ((5 << 8) | 0x7f))' failed. Aborted I'm guess that is not the expected outcome, is that the same failure you saw? --- /* -*- Mode: C; tab-width: 8; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ #include #include #include #include #include #include #include #include #include #include #include /** * Print the printf-like arguments to stdout as atomic-ly as we can * manage. Async-signal-safe. Does not flush stdio buffers (doing so * isn't signal safe). */ __attribute__((format(printf, 1, 2))) inline static int atomic_printf( const char* fmt, ...) { va_list args; char buf[1024]; int len; va_start(args, fmt); len = vsnprintf(buf, sizeof(buf) - 1, fmt, args); va_end(args); return write(STDOUT_FILENO, buf, len); } /** * Write |str| on its own line to stdout as atomic-ly as we can * manage. Async-signal-safe. Does not flush stdio buffers (doing so * isn't signal safe). */ inline static int atomic_puts(const char* str) { return atomic_printf("%s\n", str); } inline static int check_cond(int cond) { if (!cond) { atomic_printf("FAILED: errno=%d (%s)\n", errno, strerror(errno)); } return cond; } #define test_assert(cond) assert("FAILED: !" && check_cond(cond)) #define NEW_VALUE 0xabcdef static void breakpoint(void) {} static char watch_var; int main(void) { pid_t child; int status; int pipe_fds[2]; test_assert(0 == pipe(pipe_fds)); if (0 == (child = fork())) { char ch; read(pipe_fds[0], &ch, 1); breakpoint(); watch_var = 1; return 77; } test_assert(0 == ptrace(PTRACE_ATTACH, child, NULL, NULL)); test_assert(child == waitpid(child, &status, 0)); test_assert(status == ((SIGSTOP << 8) | 0x7f)); test_assert(1 == write(pipe_fds[1], "x", 1)); test_assert(0 == ptrace(PTRACE_POKEUSER, child, (void*)offsetof(struct user, u_debugreg[0]), (void*)breakpoint)); /* Enable DR0 break-on-exec */ test_assert(0 == ptrace(PTRACE_POKEUSER, child, (void*)offsetof(struct user, u_debugreg[7]), (void*)0x1)); test_assert(0 == ptrace(PTRACE_CONT, child, NULL, NULL)); test_assert(child == waitpid(child, &status, 0)); test_assert(status == ((SIGTRAP << 8) | 0x7f)); test_assert(0x1 == ptrace(PTRACE_PEEKUSER, child, (void*)offsetof(struct user, u_debugreg[6]))); test_assert(0 == ptrace(PTRACE_POKEUSER, child, (void*)offsetof(struct user, u_debugreg[0]), &watch_var)); /* Enable DR0 break-on-write */ test_assert(0 == ptrace(PTRACE_POKEUSER, child, (void*)offsetof(struct user, u_debugreg[7]), (void*)0x10001)); test_assert(0 == ptrace(PTRACE_CONT, child, NULL, NULL)); test_assert(child == waitpid(child, &status, 0)); test_assert(status == ((SIGTRAP << 8) | 0x7f)); test_assert(0x1 == ptrace(PTRACE_PEEKUSER, child, (void*)offsetof(struct user, u_debugreg[6]))); test_assert(0 == ptrace(PTRACE_DETACH, child, NULL, NULL)); test_assert(child == waitpid(child, &status, 0)); test_assert(WIFEXITED(status)); test_assert(WEXITSTATUS(status) == 77); atomic_puts("EXIT-SUCCESS"); return 0; }