Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3542485pxb; Mon, 24 Jan 2022 11:49:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4JYhslvNPkbel7Xos3Qjqa74ug1pLzYx9uAMfg4J0Q7lFuki1zVhPPprvPR4ypMSoECNO X-Received: by 2002:a05:6a00:1345:b0:4c8:fc0f:4495 with SMTP id k5-20020a056a00134500b004c8fc0f4495mr6833804pfu.29.1643053778388; Mon, 24 Jan 2022 11:49:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643053778; cv=none; d=google.com; s=arc-20160816; b=WwNohBzzRQ1AMlaD09KIsyBAD7j9paiCUavRRO9Muu9VChxw1+nxOtZuVwb2EWrfaX cp4rm9M/6uVszjzb2SdP2eB0HzYBlHS5GVeF+zIaDXNIDzcbn6xSm4bEklL3krUvvikT ygYoAM/JvY9dPcz+qlqAlKlyYCSe6dsCDSBo3oPdhrK+nbMtMGnnEcdYUNAymIcyRwLV rLGgyEUbFKWYShLLaS/w0IHkFNyCgQ8pm3Y0xSNHziGdPMki7RewOlQ6N8SltAPnfxD1 o2P8MYA5onOLmLZlpAN20u6l9aDRFU+XTsRJ2y+W8zEFnuzGf+S4bCxPSCGi4v9uRhzx 0CDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/XjTstEAGTMnS2cfhATsR9x5w6K0TN8X9h4vHjvkVrw=; b=LfBcWywudkkXA0GvybFJKbAjf4iRGp+a2Qz7W0W1cUlKqB8pj7wiYPnkQE6VCcFo/V OHdk3jfBu+PtR3vvBmGyd5MhxSA0P8kFSprrQc/+EpAO1riCOYoqlD62ZlmBMmmJSD3p hEnK+tYPE4JLEiKfkoUXd0Lbk9iHwCzqV9FjSUYiFUpUG1scakxGjyAc2Y00py4Mwnb9 FrjFWOUn6x3j0yULA2P8+p2aA/2L/DWZxWAaYujIpOWj+hGN8ZIGhRqfGt0zkNmLcFwh QbkoAqp67RiWzl5c1RxsBhTNDQwRngXk716FqiTg/ZZBG8PVf3gTqCXdbMqOdk0d9gEg ajLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=IyNV3VAB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id il16si261571pjb.106.2022.01.24.11.49.25; Mon, 24 Jan 2022 11:49:38 -0800 (PST) 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=pass header.i=@linux.dev header.s=key1 header.b=IyNV3VAB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245073AbiAXSFd (ORCPT + 99 others); Mon, 24 Jan 2022 13:05:33 -0500 Received: from out2.migadu.com ([188.165.223.204]:13779 "EHLO out2.migadu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244935AbiAXSFV (ORCPT ); Mon, 24 Jan 2022 13:05:21 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1643047519; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/XjTstEAGTMnS2cfhATsR9x5w6K0TN8X9h4vHjvkVrw=; b=IyNV3VAB/t0xjLzGOgv309VybgWXRFeywRGdKZZV4iWmY3e4kmKdNicqqTqZ0zN6pNo8pb Dz0IPusOEJkjC1XcK7aZ0CY5vehv5/xzm45oSN0+WTwFS1+6OxePIrkEnh8zjQNUZ/2XdF maXcYOD2z9VsCMIHn0R0EO1mtu8+Iuw= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, linux-mm@kvack.org, Vincenzo Frascino , Catalin Marinas , Will Deacon , Mark Rutland , linux-arm-kernel@lists.infradead.org, Peter Collingbourne , Evgenii Stepanov , linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH v6 22/39] kasan, fork: reset pointer tags of vmapped stacks Date: Mon, 24 Jan 2022 19:04:56 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrey Konovalov 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. Signed-off-by: Andrey Konovalov Reviewed-by: Alexander Potapenko --- Changes v2->v3: - Update patch description. --- kernel/fork.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/fork.c b/kernel/fork.c index d75a528f7b21..57d624f05182 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -254,6 +254,7 @@ static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node) * so cache the vm_struct. */ if (stack) { + stack = kasan_reset_tag(stack); tsk->stack_vm_area = find_vm_area(stack); tsk->stack = stack; } -- 2.25.1