From patchwork Wed Nov 2 11:06:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 13027971 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 58028C4332F for ; Wed, 2 Nov 2022 11:06:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CDD6F8E0003; Wed, 2 Nov 2022 07:06:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C8CC88E0001; Wed, 2 Nov 2022 07:06:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B2E228E0003; Wed, 2 Nov 2022 07:06:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A29F78E0001 for ; Wed, 2 Nov 2022 07:06:18 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 553D9AB130 for ; Wed, 2 Nov 2022 11:06:18 +0000 (UTC) X-FDA: 80088223236.15.8E1ACF7 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf01.hostedemail.com (Postfix) with ESMTP id 5D7A34000B for ; Wed, 2 Nov 2022 11:06:16 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id h9-20020a25e209000000b006cbc4084f2eso16108597ybe.23 for ; Wed, 02 Nov 2022 04:06:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=ZbeyMEB1N3HnW3KuOlIdq7/dvvJzr15HTa/zFi9USr4=; b=Zys9RxGxneSiAkiaMSLp0fMMah4Q4Z9cQekcJkJNg09vNC8uJQw/eYHIdshUK8sloS ooGakxYdVsGGFtO0vf+eL1zU+0H2llK4TNEmcMhroLHzQrTPZfBWQDBojDOhblkUEr4Y VlVIHNHQhO38wMiB66DPLA3LFQdtHMrbm5ZhgUQeygogmoqNQKhuvL5oPo0DAC2/5AVe qCxhIyoFmRsOF+cCGGErqjcW2MS+JPt+pV98fCT/Hsinr2F1udxrRJ8ikXkJHQoEIYa3 nXngezqkGCOS882wdt6JuoQoJ6omP88TBbF3foaf3Ou/PIbwm73m0hBRCxKUIYBtx6df B0dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ZbeyMEB1N3HnW3KuOlIdq7/dvvJzr15HTa/zFi9USr4=; b=XoI7Nr97LvRRdKhA4zaX1xC+qLhdKVKN0Wl+3er2wn8EDrHJlWL1UUzoz0yZyw20TK eKXkQm0M5AZBWHrDv+Jicny2ZwORs1iG34hZVncEWkW3cJmXXitIvsAgPoES7T1LX7+C qC2WvBUm/qDmhlSUJcAS9YmQD3B5CsEaqw4f2yM8fj9ZNCHUMF9wHtDPqik2jZ+krO4g I3BFiY7PN/sPdPApqynYK94IxcvNPUsoGGI6DDOEsPV6pwrouOKrMZlY2S3LCi1v+gXA zsaTTbjeAxTnMRWvoeyMCZMPpRLMp8dRXJObfOKiv8b6MzgfNDJK12dcoL3pxauaafWq WNyA== X-Gm-Message-State: ACrzQf1cY57G22xrwNHQieOgA6AkEn3pUTQNgRUvjy6AbHQS/CCrK2Ku VmkK++YvXsxhtim3rPcmvqbtBacg54A= X-Google-Smtp-Source: AMsMyM4hS7slDYBeV5u3u/VgJ5G2C644lj/pYCkRoBPNBgg3H29Xs+iNPOC5zuesvbC6tPeF8YMpu8KFAb4= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:7f41:af20:8:a96d]) (user=glider job=sendgmr) by 2002:a25:2187:0:b0:6b0:1abc:2027 with SMTP id h129-20020a252187000000b006b01abc2027mr22399213ybh.348.1667387175509; Wed, 02 Nov 2022 04:06:15 -0700 (PDT) Date: Wed, 2 Nov 2022 12:06:07 +0100 Mime-Version: 1.0 X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog Message-ID: <20221102110611.1085175-1-glider@google.com> Subject: [PATCH 1/5] kmsan: core: kmsan_in_runtime() should return true in NMI context From: Alexander Potapenko To: glider@google.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Dmitry Vyukov , Marco Elver , Peter Zijlstra ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667387176; a=rsa-sha256; cv=none; b=sm2cGqBdIQh+uCotQsZwR9hXIAXKFpnS+rwtwfyWTv9TLk6eSFP6+fvpmN9Xvis7PPQoKs WK7tYtxbYMNgati2kC6xKNDjrlf9TEEbs8N4YMsQrDjAOlhYXl8kzvIH3I12h2Ly2lbnen 51RKS8HXhwPbqAtYgLkoHi6uUz21df0= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Zys9RxGx; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf01.hostedemail.com: domain of 3J09iYwYKCHAUZWRSfUccUZS.QcaZWbil-aaYjOQY.cfU@flex--glider.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3J09iYwYKCHAUZWRSfUccUZS.QcaZWbil-aaYjOQY.cfU@flex--glider.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667387176; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=ZbeyMEB1N3HnW3KuOlIdq7/dvvJzr15HTa/zFi9USr4=; b=uOGVpOWXKa28faoIKstrcafzyQdYsTKgy2LEcZZdxhi4sr5NHKwREX2Pc9OLTOXGg0P2o7 OFV80RCpoTQO9mYCnbO8ycfI3mmAK5+x9vbKsVMrW5M9wbQOaWISg1hQhJrlAwfFRw8vxP DPpcPsuXaJtJ5nnSKYacIed66NSFYJg= X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 5D7A34000B X-Rspam-User: Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Zys9RxGx; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf01.hostedemail.com: domain of 3J09iYwYKCHAUZWRSfUccUZS.QcaZWbil-aaYjOQY.cfU@flex--glider.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3J09iYwYKCHAUZWRSfUccUZS.QcaZWbil-aaYjOQY.cfU@flex--glider.bounces.google.com X-Stat-Signature: hc8ztacbcnhyrm3gu1zrzrbcfpy76nzr X-HE-Tag: 1667387176-20488 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: Without that, every call to __msan_poison_alloca() in NMI may end up allocating memory, which is NMI-unsafe. Cc: Andrew Morton Cc: Dmitry Vyukov Cc: Marco Elver Cc: Peter Zijlstra (Intel) Link: https://lore.kernel.org/lkml/20221025221755.3810809-1-glider@google.com/ Signed-off-by: Alexander Potapenko Acked-by: Peter Zijlstra (Intel) --- mm/kmsan/kmsan.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/kmsan/kmsan.h b/mm/kmsan/kmsan.h index 961eb658020aa..3cd2050a33e6a 100644 --- a/mm/kmsan/kmsan.h +++ b/mm/kmsan/kmsan.h @@ -125,6 +125,8 @@ static __always_inline bool kmsan_in_runtime(void) { if ((hardirq_count() >> HARDIRQ_SHIFT) > 1) return true; + if (in_nmi()) + return true; return kmsan_get_context()->kmsan_in_runtime; }