From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0298AC433F5 for ; Wed, 1 Dec 2021 13:56:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F4CA6B0074; Wed, 1 Dec 2021 08:56:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 57D196B0075; Wed, 1 Dec 2021 08:56:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F7686B0078; Wed, 1 Dec 2021 08:56:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0234.hostedemail.com [216.40.44.234]) by kanga.kvack.org (Postfix) with ESMTP id 2F6D26B0074 for ; Wed, 1 Dec 2021 08:56:09 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E29178249980 for ; Wed, 1 Dec 2021 13:55:58 +0000 (UTC) X-FDA: 78869373996.22.410746A Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by imf13.hostedemail.com (Postfix) with ESMTP id 82C79104628D for ; Wed, 1 Dec 2021 13:55:58 +0000 (UTC) Received: by mail-ed1-f47.google.com with SMTP id g14so102085706edb.8 for ; Wed, 01 Dec 2021 05:55:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sSt3Unx0/Qaq0FKjSY7ns1ciES5Q464PSLz6H6FDGfQ=; b=gJ/UlzgyMQ2McJ7WN/9L0KBubFxWZVI4CASZkdqyA3frk7WdXC1wKI+g6w9Jnw7C+0 f46wilN0nuOdKGOl0XPMug2Uan5MCuBvnFpU+kdVo7yikHIwcEGNegiFPhbYFUkOW7F0 DdPyI2zHgvTfyFguFpf95neo67oC16a1NwxkC2mGWIur+j/zY3SMFO3ZwemyaOpuUnoo /PYnQ3ZXbdK6ma4R+TMx/UIPB+x1txZSSjR5Romg9zn5aTsSJrMX/1m3W2RWjexd4/an VCUkNWY1pTyWzH6UFic8uxachWdyRecVsWTJM/DLfH7sGKC0ePbW8JDWBLGWbyvAV/E+ 2jww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sSt3Unx0/Qaq0FKjSY7ns1ciES5Q464PSLz6H6FDGfQ=; b=agoMtaehzYnrkWZQRGxOMJuicL6xjo8MAdG6wWr/RyOFfNevVoxgFjD0jf+Y9C5g4W d97cFI9GsGayJLuivbcKy0JbgKLobpxhB8KHaVLqXaoII1Qe3Gb67beYmliidx23BLto MXne17zm+kIiHabYoQ8hqYjQ2xJ5odbm7yxdzKQC4JXLuZvR8hniaNkFfy+WODkoj3Js Ugq0xz8KjKkUaQV5hTdePrTZCdOwQGBl7KRk6/uS/6rfLWt/mjpA5m6Zsl0c+9Gbustq Mcqq6b7cQ52yg9GRYZBa+GSOFR3ay+A/cHkORjYo1CbRhYyctNj4tOPXLUbmz7+UcOwj O/Fg== X-Gm-Message-State: AOAM531mq+ggJKL08aFTKvUNlUUkmifCl9gqVoD9VdI+teM1qbMfk5G7 UdkoTAIhSqoJSmu2uLA8Jii6oSbQIZo6YetBCI3S2g== X-Google-Smtp-Source: ABdhPJwclv1vk+2ywUTPu0BpiV0wKbr52GqiTSYyY7qZKtTqCd2OmYjoujCv6mvjVoTJUS6dVMzInXlDQmxk7Gis7YA= X-Received: by 2002:a17:906:2b12:: with SMTP id a18mr7290462ejg.254.1638366956867; Wed, 01 Dec 2021 05:55:56 -0800 (PST) MIME-Version: 1.0 References: <20211123214814.3756047-1-pasha.tatashin@soleen.com> <20211123214814.3756047-4-pasha.tatashin@soleen.com> In-Reply-To: From: Pasha Tatashin Date: Wed, 1 Dec 2021 08:55:21 -0500 Message-ID: Subject: Re: [PATCH 3/3] x86: mm: add x86_64 support for page table check To: Jiri Slaby Cc: LKML , linux-mm , Linux Doc Mailing List , Andrew Morton , David Rientjes , Paul Turner , weixugc@google.com, Greg Thelen , Ingo Molnar , Jonathan Corbet , Will Deacon , Mike Rapoport , Kees Cook , Thomas Gleixner , Peter Zijlstra , masahiroy@kernel.org, Sami Tolvanen , Dave Hansen , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , frederic@kernel.org, "H. Peter Anvin" , "Aneesh Kumar K.V" Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 82C79104628D Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b="gJ/Ulzgy"; dmarc=none; spf=pass (imf13.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.208.47 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com X-Stat-Signature: z4xafg3d4j6f69eb9ttmenwtdyr7mr51 X-HE-Tag: 1638366958-459027 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Dec 1, 2021 at 3:44 AM Jiri Slaby wrote: > > On 01. 12. 21, 9:00, Jiri Slaby wrote: > > On 23. 11. 21, 22:48, Pasha Tatashin wrote: > >> Add page table check hooks into routines that modify user page tables. > > > > Hi, > > > > I bisected to this as this causes crashes during modules load: > > And it's not enough to unset CONFIG_PAGE_TABLE_CHECK_ENFORCED. I had to > unset CONFIG_PAGE_TABLE_CHECK completely to get rid of this. Hi, Thanks for reporting this. Seems like module load for some reasons does not like the static branches. However, I was not able to repro this. Could you please share your config and the module that you were loading? Thank you, Pasha > > > #PF: supervisor write access in kernel mode > > #PF: error_code(0x0003) - permissions violation > > PGD 6d615067 P4D 6d615067 PUD 6d616063 PMD 800000006d2001e1 > > Oops: 0003 [#1] PREEMPT SMP PTI > > CPU: 0 PID: 6189 Comm: modprobe Kdump: loaded Tainted: G I E > > 5.16.0-rc2-next-20211129-vanilla #3 > > 83846a405f0e3937f5c8dfbc7d449622b8f46369 > > Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./To be > > filled by O.E.M., BIOS SDBLI944.86P 05/08/2007 > > RIP: 0010:jump_label_module_notify (kernel/jump_label.c:370 > > kernel/jump_label.c:670 kernel/jump_label.c:748) > > Code: 00 48 8b 43 08 a8 02 0f 85 e9 00 00 00 48 83 e0 fc 48 c7 02 00 00 > > 00 00 48 89 42 08 48 8b 43 08 83 e0 03 48 09 c2 48 83 ca 02 <48> 89 53 > > 08 4d 89 66 10 49 89 6e 08 48 8b 43 08 a8 02 0f 84 98 00 > > All code > > ======== > > 0: 00 48 8b add %cl,-0x75(%rax) > > 3: 43 08 a8 02 0f 85 e9 rex.XB or %bpl,-0x167af0fe(%r8) > > a: 00 00 add %al,(%rax) > > c: 00 48 83 add %cl,-0x7d(%rax) > > f: e0 fc loopne 0xd > > 11: 48 c7 02 00 00 00 00 movq $0x0,(%rdx) > > 18: 48 89 42 08 mov %rax,0x8(%rdx) > > 1c: 48 8b 43 08 mov 0x8(%rbx),%rax > > 20: 83 e0 03 and $0x3,%eax > > 23: 48 09 c2 or %rax,%rdx > > 26: 48 83 ca 02 or $0x2,%rdx > > 2a:* 48 89 53 08 mov %rdx,0x8(%rbx) <-- > > trapping instruction > > 2e: 4d 89 66 10 mov %r12,0x10(%r14) > > 32: 49 89 6e 08 mov %rbp,0x8(%r14) > > 36: 48 8b 43 08 mov 0x8(%rbx),%rax > > 3a: a8 02 test $0x2,%al > > 3c: 0f .byte 0xf > > 3d: 84 .byte 0x84 > > 3e: 98 cwtl > > ... > > > > Code starting with the faulting instruction > > =========================================== > > 0: 48 89 53 08 mov %rdx,0x8(%rbx) > > 4: 4d 89 66 10 mov %r12,0x10(%r14) > > 8: 49 89 6e 08 mov %rbp,0x8(%r14) > > c: 48 8b 43 08 mov 0x8(%rbx),%rax > > 10: a8 02 test $0x2,%al > > 12: 0f .byte 0xf > > 13: 84 .byte 0x84 > > 14: 98 cwtl > > ... > > RSP: 0018:ffffaf4dc051fbe8 EFLAGS: 00010282 > > RAX: 0000000000000001 RBX: ffffffff931ee760 RCX: 0000000000000001 > > RDX: ffff9d1aa7d43883 RSI: ffffffff91c50aa0 RDI: ffffffff931ee760 > > RBP: ffffffffc0782000 R08: 0000000000000020 R09: 0000000000000000 > > R10: ffff9d1aa7d43880 R11: 0000000000000000 R12: ffffffffc079a980 > > R13: ffffffffc0784080 R14: ffff9d1aa7d43ca0 R15: ffffffffc0782008 > > FS: 00007f87104b8740(0000) GS:ffff9d1b45c00000(0000) > > knlGS:0000000000000000 > > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > > CR2: ffffffff931ee768 CR3: 000000010fdce000 CR4: 00000000000006f0 > > Call Trace: > > > > blocking_notifier_call_chain_robust (kernel/notifier.c:83 > > kernel/notifier.c:118 kernel/notifier.c:283 kernel/notifier.c:271) > > load_module (./include/linux/notifier.h:198 kernel/module.c:3923 > > kernel/module.c:4100) > > __do_sys_finit_module (kernel/module.c:4224) > > do_syscall_64 (arch/x86/entry/common.c:50 arch/x86/entry/common.c:80) > > entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:113) > > > >> Signed-off-by: Pasha Tatashin > >> --- > >> arch/x86/Kconfig | 1 + > >> arch/x86/include/asm/pgtable.h | 29 +++++++++++++++++++++++++++-- > >> 2 files changed, 28 insertions(+), 2 deletions(-) > >> > > > > regards, > > > -- > js > suse labs