From patchwork Fri Mar 25 01:11:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12791151 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 17BB2C433FE for ; Fri, 25 Mar 2022 01:11:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A42EB8D000A; Thu, 24 Mar 2022 21:11:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9F15D8D0005; Thu, 24 Mar 2022 21:11:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E0B58D000A; Thu, 24 Mar 2022 21:11:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0189.hostedemail.com [216.40.44.189]) by kanga.kvack.org (Postfix) with ESMTP id 7A7D88D0005 for ; Thu, 24 Mar 2022 21:11:11 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 409D1A5D35 for ; Fri, 25 Mar 2022 01:11:11 +0000 (UTC) X-FDA: 79281129942.27.97A9725 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf19.hostedemail.com (Postfix) with ESMTP id BDE821A001E for ; Fri, 25 Mar 2022 01:11:10 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A8662B81DE2; Fri, 25 Mar 2022 01:11:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D277C340EC; Fri, 25 Mar 2022 01:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1648170668; bh=WB80sFaBxyAUXBG5EJJVF/0zD2Pwiyr+4hsi276rbCI=; h=Date:To:From:In-Reply-To:Subject:From; b=AxSGhCLZoKYIKvIWV/SU2NGHBQOa+jFZJ1kcvW0yXhsJiVpQohyS4p0VNq2mki3gE Ty3DZx36eaoyVr7ufH0kErgJj233FZP3NQAWh8zROu+q4sHoNTa302Aaj6ng1Ri9h2 083QdsYNQsvJOOpLm1ZESjvs8Zom6/TscQkxzCCM= Date: Thu, 24 Mar 2022 18:11:07 -0700 To: will@kernel.org,vincenzo.frascino@arm.com,ryabinin.a.a@gmail.com,pcc@google.com,mark.rutland@arm.com,glider@google.com,eugenis@google.com,elver@google.com,dvyukov@google.com,catalin.marinas@arm.com,andreyknvl@google.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220324180758.96b1ac7e17675d6bc474485e@linux-foundation.org> Subject: [patch 051/114] kasan, fork: reset pointer tags of vmapped stacks Message-Id: <20220325011108.5D277C340EC@smtp.kernel.org> X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: 4g6om6xdk8kti5dnmqnr36jjxybeewdk Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=AxSGhCLZ; dmarc=none; spf=pass (imf19.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Rspamd-Queue-Id: BDE821A001E X-HE-Tag: 1648170670-185380 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: From: Andrey Konovalov Subject: kasan, fork: reset pointer tags of vmapped stacks Once tag-based KASAN modes start tagging vmalloc() allocations, kernel stacks start getting tagged if CONFIG_VMAP_STACK is enabled. Reset the tag of kernel stack pointers after allocation in alloc_thread_stack_node(). For SW_TAGS KASAN, when CONFIG_KASAN_STACK is enabled, the instrumentation can't handle the SP register being tagged. For HW_TAGS KASAN, there's no instrumentation-related issues. However, the impact of having a tagged SP register needs to be properly evaluated, so keep it non-tagged for now. Note, that the memory for the stack allocation still gets tagged to catch vmalloc-into-stack out-of-bounds accesses. Link: https://lkml.kernel.org/r/c6c96f012371ecd80e1936509ebcd3b07a5956f7.1643047180.git.andreyknvl@google.com Signed-off-by: Andrey Konovalov Reviewed-by: Alexander Potapenko Acked-by: Marco Elver Cc: Andrey Ryabinin Cc: Catalin Marinas Cc: Dmitry Vyukov Cc: Evgenii Stepanov Cc: Mark Rutland Cc: Peter Collingbourne Cc: Vincenzo Frascino Cc: Will Deacon Signed-off-by: Andrew Morton --- kernel/fork.c | 2 ++ 1 file changed, 2 insertions(+) --- a/kernel/fork.c~kasan-fork-reset-pointer-tags-of-vmapped-stacks +++ a/kernel/fork.c @@ -326,6 +326,8 @@ static int alloc_thread_stack_node(struc * so cache the vm_struct. */ tsk->stack_vm_area = vm; + if (stack) + stack = kasan_reset_tag(stack); tsk->stack = stack; return 0; }