Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp254648pxm; Wed, 2 Mar 2022 14:41:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTbbaQAGGm/8QgnMMf+1PTd/VWh7c0+YzLhbnJ6E6xXtjhDNPyx5keO1ujlYGPFiscIYHr X-Received: by 2002:a63:224a:0:b0:368:e837:3262 with SMTP id t10-20020a63224a000000b00368e8373262mr27778129pgm.546.1646260896792; Wed, 02 Mar 2022 14:41:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646260896; cv=none; d=google.com; s=arc-20160816; b=E7vHCLB76cg5OTFqeBpp15K0p5Dz9sLhybENINfqqK6o4JbOV0ZNTkb9hqW1FR47X1 8C2DEaab8AWAMy2C3i12SP1L/g0qxFCNslWE6sjRwvmBViOq8wvdkmW26jeuGDDw8tGO neHhiialtnbpHCQyzFbB9ZIvPAlsVpH3ahvtCWX/XYLTv9FRsiMAl9lFmFeemd2+H1pv SwRVykCHzpyxuh449zSOSuJNYQoBxveZ7PRcl7TGjDVHx0z2S9+yn26JVw38q2cte0JC XL8wfZ18P7qK30rUpDsucMIsUetGGB/NpKwaGCT41RbmjfFNPWGWl4KHtea1wx9k8L3p lTYw== 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=Y1tVVcjXP0EERa5LTGRHGhA3byiWB4oonSnJ546jpQY=; b=p46XOZVPq2752Vjfx0ZHLU+9FJawBuanstIwhDRLjo/0Eh/ZEYUrEM09mIh8lcqJm3 8Z2AUxoYg0NfFn+kcGiQfnnRBrpdjZIz2CLQWNNEKAtlxZkC3gAlv5jUXUQRecpCfHeE KwV3el5xQg7NEsnO/7qurshRTCAPBSQpv8j4w7c4nf1LL8yXVcDacGs14pLaUgCnPueO kZJXfF1tT87E4JhFYrEf7mdm2wwIweHxblhyxxEi4Du4WUhWMbMJgQX6Bk9IT/b4K2wr BRbPz0xNKDz7Mi8euHXpMod0vbcqAROrjDPixzh0wX7r+7386L9VS3mZ0Q178WGKIjG8 VtxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Lt4GrBE4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d191-20020a621dc8000000b004e17e15a8fdsi324302pfd.198.2022.03.02.14.41.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 14:41:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Lt4GrBE4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1330D54BD3; Wed, 2 Mar 2022 14:36:56 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243023AbiCBQhy (ORCPT + 99 others); Wed, 2 Mar 2022 11:37:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242840AbiCBQhf (ORCPT ); Wed, 2 Mar 2022 11:37:35 -0500 Received: from out1.migadu.com (out1.migadu.com [IPv6:2001:41d0:2:863f::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C2CBCEA01 for ; Wed, 2 Mar 2022 08:36:52 -0800 (PST) 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=1646239009; 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=Y1tVVcjXP0EERa5LTGRHGhA3byiWB4oonSnJ546jpQY=; b=Lt4GrBE4AcuD8i0t9r97+W9VG/37yQMTx3JTaWtBhqz73Ts6O4gHTwfWe/kSPuGcx5X2Mo 5T5ocOiZw0whxQHDZxGV14Ovfb18EmMLsBiOoSZhPraZ349MCqlDwi5bfAklOErZc2h5/5 5aV2NFs1OglbiLieI37hZm7xGihH/Vs= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm 05/22] kasan: print basic stack frame info for SW_TAGS Date: Wed, 2 Mar 2022 17:36:25 +0100 Message-Id: <029aaa87ceadde0702f3312a34697c9139c9fb53.1646237226.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrey Konovalov Software Tag-Based mode tags stack allocations when CONFIG_KASAN_STACK is enabled. Print task name and id in reports for stack-related bugs. Signed-off-by: Andrey Konovalov --- mm/kasan/kasan.h | 2 +- mm/kasan/report_sw_tags.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h index d1e111b7d5d8..4447df0d7343 100644 --- a/mm/kasan/kasan.h +++ b/mm/kasan/kasan.h @@ -274,7 +274,7 @@ void *kasan_find_first_bad_addr(void *addr, size_t size); const char *kasan_get_bug_type(struct kasan_access_info *info); void kasan_metadata_fetch_row(char *buffer, void *row); -#if defined(CONFIG_KASAN_GENERIC) && defined(CONFIG_KASAN_STACK) +#if defined(CONFIG_KASAN_STACK) void kasan_print_address_stack_frame(const void *addr); #else static inline void kasan_print_address_stack_frame(const void *addr) { } diff --git a/mm/kasan/report_sw_tags.c b/mm/kasan/report_sw_tags.c index d2298c357834..44577b8d47a7 100644 --- a/mm/kasan/report_sw_tags.c +++ b/mm/kasan/report_sw_tags.c @@ -51,3 +51,14 @@ void kasan_print_tags(u8 addr_tag, const void *addr) pr_err("Pointer tag: [%02x], memory tag: [%02x]\n", addr_tag, *shadow); } + +#ifdef CONFIG_KASAN_STACK +void kasan_print_address_stack_frame(const void *addr) +{ + if (WARN_ON(!object_is_on_stack(addr))) + return; + + pr_err("The buggy address belongs to stack of task %s/%d\n", + current->comm, task_pid_nr(current)); +} +#endif -- 2.25.1