From patchwork Tue Jun 22 06:51:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zeng Tao X-Patchwork-Id: 465158 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp373916jao; Mon, 21 Jun 2021 23:53:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVurYoPybcudY3bv0q+UI0+MPWp5HTP3dxQpfX61sPed5CzlxF+QnbFF8xDhjpM8qebmxF X-Received: by 2002:a17:907:2d07:: with SMTP id gs7mr2289330ejc.375.1624344786025; Mon, 21 Jun 2021 23:53:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624344786; cv=none; d=google.com; s=arc-20160816; b=CuIZfWI4xPdxL485J9HgjhkqwQCx76vMtaGe4NY+GuQNxMyYC3jFjaXECqaRDBA6Ao fpZG5Pp7y8kMIfBgGvP/yR5mJARk1ZBVZ9iYdciLrvd2g8TG6OnPzVGR2KWxn0d2pgJP UCV09bjK5gMgtX93d7syKj4CL8TxqYtFE9+XqUjvhbyaMvowIUa2C1WX55HQ4u1Rrvf1 2PucV6bn/A7/TKSU0KnQpHVm9yix8UG9cDjhOlUkd+9h7zBUwOAWaWIB7SD53E1qZsFu c1itcD93i8SNVzECEebWDmklXXFXNAO05cznSmbdw7oaX7FkNhr0ScsJQXS9XEA0CQZO srKQ== 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 :message-id:date:subject:cc:to:from; bh=s4Ubjay0spo9NLAkeELabUlnzeZzJ9h3HUlhnnqxwNg=; b=E9nBx763SvGbRKdk3EshWaoVyZW4+DVt1AF7BkaYChKM6uhlDX57djbeEa9aWGqUSz 9KY2ESKGDroqSIfpRPrj/zmBREWQf0DhUilDvxFYZfso9/4tPXM/pSZfw3AMgpy072YV 5czPLd8e/9el31V9cxxWMpqGSx0MGH2/IsBY3hGQ9og0bCwHSINBbRrEvUV1oWvYFMOT 30xhAde2JPV6r8xAhx96WDlUkN8UyxelSsHrOvL9xIUEbkPHdqn+ckjxKAytRA+3FciW HOrfItThkG2TG18kbvjY8zI2ltYv5yEk+4eZDzqldUUDen82TebUlLAP4DmxqZ6j0Etn gvVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hisilicon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f19si10346481edu.388.2021.06.21.23.53.05; Mon, 21 Jun 2021 23:53:06 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hisilicon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229810AbhFVGzT (ORCPT + 12 others); Tue, 22 Jun 2021 02:55:19 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:11078 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbhFVGzT (ORCPT ); Tue, 22 Jun 2021 02:55:19 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4G8H8B0qbpzZhQD; Tue, 22 Jun 2021 14:50:02 +0800 (CST) Received: from dggpemm000003.china.huawei.com (7.185.36.128) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 22 Jun 2021 14:53:02 +0800 Received: from localhost.localdomain (10.67.165.2) by dggpemm000003.china.huawei.com (7.185.36.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 22 Jun 2021 14:53:01 +0800 From: Zeng Tao To: CC: Alexey Dobriyan , Andi Kleen , David Howells , , Andrew Morton , Stephen Rothwell Subject: [PATCH] afs: fix tracepoint string placement with built-in AFS Date: Tue, 22 Jun 2021 14:51:37 +0800 Message-ID: <20210622065137.3849512-1-prime.zeng@hisilicon.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm000003.china.huawei.com (7.185.36.128) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Alexey Dobriyan I was adding custom tracepoint to the kernel, grabbed full F34 kernel .config, disabled modules and booted whole shebang as VM kernel. Then did perf record -a -e ... It crashed: general protection fault, probably for non-canonical address 0x435f5346592e4243: 0000 [#1] SMP PTI CPU: 1 PID: 842 Comm: cat Not tainted 5.12.6+ #26 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-1.fc33 04/01/2014 RIP: 0010:t_show+0x22/0xd0 Then reproducer was narrowed to # cat /sys/kernel/tracing/printk_formats Original F34 kernel with modules didn't crash. So I started to disable options and after disabling AFS everything started working again. The root cause is that AFS was placing char arrays content into a section full of _pointers_ to strings with predictable consequences. Non canonical address 435f5346592e4243 is "CB.YFS_" which came from CM_NAME macro. The fix is to create char array and pointer to it separatedly. Steps to reproduce: CONFIG_AFS=y CONFIG_TRACING=y # cat /sys/kernel/tracing/printk_formats Link: https://lkml.kernel.org/r/YLAXfvZ+rObEOdc/@localhost.localdomain Fixes: 8e8d7f13b6d5a9 ("afs: Add some tracepoints") Signed-off-by: Alexey Dobriyan (SK hynix) Cc: Andi Kleen Cc: David Howells Cc: Signed-off-by: Andrew Morton Signed-off-by: Stephen Rothwell --- fs/afs/cmservice.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.30.0 diff --git a/fs/afs/cmservice.c b/fs/afs/cmservice.c index d3c6bb22c5f4..d39c63b13d9f 100644 --- a/fs/afs/cmservice.c +++ b/fs/afs/cmservice.c @@ -30,8 +30,9 @@ static void SRXAFSCB_TellMeAboutYourself(struct work_struct *); static int afs_deliver_yfs_cb_callback(struct afs_call *); #define CM_NAME(name) \ - char afs_SRXCB##name##_name[] __tracepoint_string = \ - "CB." #name + const char afs_SRXCB##name##_name[] = "CB." #name; \ + static const char *_afs_SRXCB##name##_name __tracepoint_string =\ + afs_SRXCB##name##_name /* * CB.CallBack operation type