From patchwork Fri Oct 18 09:42:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11197989 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0A35C13B1 for ; Fri, 18 Oct 2019 09:43:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C155E20820 for ; Fri, 18 Oct 2019 09:43:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="nuekFE8N" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C155E20820 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B15898E0027; Fri, 18 Oct 2019 05:43:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AC53B8E0003; Fri, 18 Oct 2019 05:43:50 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9DB5E8E0027; Fri, 18 Oct 2019 05:43:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0239.hostedemail.com [216.40.44.239]) by kanga.kvack.org (Postfix) with ESMTP id 7E1FB8E0003 for ; Fri, 18 Oct 2019 05:43:50 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 1E54C182104A5 for ; Fri, 18 Oct 2019 09:43:50 +0000 (UTC) X-FDA: 76056418620.14.game20_78be7550cb935 X-Spam-Summary: 2,0,0,fc59c698a1426a01,d41d8cd98f00b204,3vimpxqykcaehmjefshpphmf.dpnmjovy-nnlwbdl.psh@flex--glider.bounces.google.com,:glider@google.com:mingo@elte.hu:vegard.nossum@oracle.com:dvyukov@google.com:,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3152:3352:3867:3868:3870:4321:5007:6117:6120:6261:6653:7901:7903:9969:10004:10400:11026:11232:11473:11658:11914:12043:12291:12296:12297:12438:12555:12895:12986:13069:13311:13357:13846:14096:14097:14181:14394:14659:14721:21080:21365:21444:21451:21627:30003:30054:30064,0,RBL:209.85.128.73:@flex--glider.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: game20_78be7550cb935 X-Filterd-Recvd-Size: 4422 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Fri, 18 Oct 2019 09:43:49 +0000 (UTC) Received: by mail-wm1-f73.google.com with SMTP id o188so2452151wmo.5 for ; Fri, 18 Oct 2019 02:43:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=UyV9UR3LSpLQrFqhYzhcJbdZOsxELV3pBAp6RXWOa7k=; b=nuekFE8NI08HFbaYwWh3SycyjxIzp03Mx5bY8k4gHVPzYVSLs6UqzpCRKYQkvas4eq FKgX+D8bk/Of+fgG/9/IZxBEl5y5k6yN2WzlHLmRmCTd3+5lHnJkbu59Wq1mJN2YK18D m24XMZED6eQ1PwnZqdAleTBmJkTaCd9PAS1EEk4vzMJY2KKcot4C6iHnk/+RR7hkOVEF X0cLINnUkFQQi4EtxZO0MucbJrqup0/11qmncJAccl07I0ZYMMGY0XI3iCGSIg2udrGi iF/iKGyEk7th19EAFZfq5iqEYEayivCf36LdyqUg177yttPshj2i0TEcSJitYSdNN8jy 1KHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=UyV9UR3LSpLQrFqhYzhcJbdZOsxELV3pBAp6RXWOa7k=; b=MDTHIO0szGeNxT0T92GTaQ1T5+8h7++sRTjaZ2f0AVileek+3/kHRR6N5EuCkw5FZb fbD/MqaA+XehNgFVnpcFnFu6Sp9/JoqnSrJNFwS1pu+4lJi2Xmh5Sembn6qYHf7mip8i 3iyraOODBTIZfnXp3TGqWIuB0LcZ9d2Tig3fpfWz79RugQ2P+MB3ZITRwW5Mnk8XMNEf faAeCAeueIIj62qh83mR/vt65Qn+Q3YWZmUSzs2FB3hxXHxr2rRdLRa/KIWCr0A7lH9D aXNR0OGZaSZt2zxZBTXMMAt6J6WAwT7FnDRC5WE/P6pQysCAjnCYJ4HuW3Gw77ODt6UA XV0w== X-Gm-Message-State: APjAAAVG7kEz4ZV9wax1MBDoRUxQcnNqSr/hnrnSi4ZVHHNU3zWcNht6 7KUl+j522kzcCKjV4Yol5wsF+gs+S4s= X-Google-Smtp-Source: APXvYqzbCCCughfRa7/mYFrp+3qLZvFtcCK9hWbc1RX8vi+ZW6rBkDy/x/eUWhICdA4XWlIZ42xohifdJvM= X-Received: by 2002:a5d:5052:: with SMTP id h18mr7361494wrt.143.1571391828470; Fri, 18 Oct 2019 02:43:48 -0700 (PDT) Date: Fri, 18 Oct 2019 11:42:50 +0200 In-Reply-To: <20191018094304.37056-1-glider@google.com> Message-Id: <20191018094304.37056-13-glider@google.com> Mime-Version: 1.0 References: <20191018094304.37056-1-glider@google.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog Subject: [PATCH RFC v1 12/26] kmsan: x86: sync metadata pages on page fault From: glider@google.com To: Alexander Potapenko Cc: Ingo Molnar , Vegard Nossum , Dmitry Vyukov , linux-mm@kvack.org 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: KMSAN assumes shadow and origin pages for every allocated page are accessible. For pages in vmalloc region those metadata pages reside in [VMALLOC_END, VMALLOC_META_END), therefore we must sync a bigger memory region. Signed-off-by: Alexander Potapenko To: Alexander Potapenko Cc: Ingo Molnar Cc: Vegard Nossum Cc: Dmitry Vyukov Cc: linux-mm@kvack.org --- Change-Id: I0d54855489870ef1180b37fe2120b601da464bf7 --- arch/x86/mm/fault.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 9ceacd1156db..d582337ba45d 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -320,7 +320,17 @@ static void dump_pagetable(unsigned long address) void vmalloc_sync_all(void) { +#ifdef CONFIG_KMSAN + /* + * For KMSAN, make sure metadata pages for vmalloc area and modules are + * also synced. + */ + sync_global_pgds(VMALLOC_START & PGDIR_MASK, VMALLOC_META_END); + sync_global_pgds(MODULES_SHADOW_START & PGDIR_MASK, + MODULES_ORIGIN_END); +#else sync_global_pgds(VMALLOC_START & PGDIR_MASK, VMALLOC_END); +#endif } /* @@ -337,7 +347,17 @@ static noinline int vmalloc_fault(unsigned long address) pte_t *pte; /* Make sure we are in vmalloc area: */ +#ifdef CONFIG_KMSAN + /* + * For KMSAN, make sure metadata pages for vmalloc area and modules are + * also synced. + */ + if (!(address >= VMALLOC_START && address < VMALLOC_META_END) && + !(address >= MODULES_SHADOW_START && + address < MODULES_ORIGIN_END)) +#else if (!(address >= VMALLOC_START && address < VMALLOC_END)) +#endif return -1; /*