Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3516643iog; Mon, 20 Jun 2022 23:36:56 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uzJZ90Z3+5LEnEQKRhh/q2ODgEY2LE+XutxjsCqOIG2NdZ90Bgq+y2T9E54xIm4H1p3blr X-Received: by 2002:a17:902:6b45:b0:168:d421:f7a8 with SMTP id g5-20020a1709026b4500b00168d421f7a8mr27736258plt.36.1655793416241; Mon, 20 Jun 2022 23:36:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655793416; cv=none; d=google.com; s=arc-20160816; b=kVvsKkEt4jZHTvT3JQGabyIS5aM+7HDUe0IIs3gFOx2mPfDWtEq7FMjIRJgiF8xjVz 1Yq+V813XAPndDfs3KBGSjAQgvkpfJAkrxVo7UBsrT+XndimiWRtfwvrRqigkxxDh51F x3dyzRb23DVPu950yYNCCrkqKb/+D9Z1nIj9UBWzpVojidMTP/H2X6F+oNryL6gl8wXy HuaF0smc6jUA5Dn1EwmB/lHRphmAzPoP/GKDCP3tUim5a/WlfFjw8isNAgci+G/F9NRC Glrh4iiLSpxwGyji7aDt2AbeTHbGJNeksg7Km1s1F5MlWzEJFgp5oOChzFHHciohehL/ Gaxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=8B6OBov+Dp//rrdGe97WOSHuT0EA9+jVckLT/ZqJALw=; b=qp90HN6m/KP8lMdYxlDjdrs7MqjDgtFpieFLwby8r9wJSSd1B0TRkVDx9UzBZk61su mYvTciAAzszVdPqfUxgBiBaet2NGSRkPZA/Plt9ukid7iyQPaNd3BRyNuCfCdbHzrqo9 yPvwnObjmFRohuNPG9/+6HrvurE/SfJN/QmkYxPXwPgUjx2/pjhn9lfq1X6d/iBMTGc6 c42o/dga9Ez7i0ugDwx0R/nn9GjLl0cN84OXxd5E5aZBNI9bIJQwrr7tsI40B7bHWum4 VJOg8KSDMc6AqOONMVDWr3PpxHPgVe8m+2l+Xl+hbtfpuhhW9qK/s9LykYQUBj0eZi6d on7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=Yti7jI5h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r10-20020a63514a000000b003fbc60e335asi21211869pgl.736.2022.06.20.23.36.44; Mon, 20 Jun 2022 23:36:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=Yti7jI5h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345131AbiFUGbh (ORCPT + 99 others); Tue, 21 Jun 2022 02:31:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232935AbiFUGbf (ORCPT ); Tue, 21 Jun 2022 02:31:35 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05D9860E3; Mon, 20 Jun 2022 23:31:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1655793095; x=1687329095; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=8B6OBov+Dp//rrdGe97WOSHuT0EA9+jVckLT/ZqJALw=; b=Yti7jI5hBRbceJ9pXq6fzHoFdzwrLgG86FXFEM+pgwt6IWXTHgdBcH11 e3gJ2ovgdZz4Y5Z2yRFjhUU62Fycm0BoKZr8RIMVjLq56v1Zos9pXnSj4 g8E2VYQmRG01d86PJr15YQX6JFlmNrLYQgRhLm0l/fQ8oc1xI4tgKueGe M=; Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-01.qualcomm.com with ESMTP; 20 Jun 2022 23:31:34 -0700 X-QCInternal: smtphost Received: from nasanex01b.na.qualcomm.com ([10.46.141.250]) by ironmsg-SD-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2022 23:31:34 -0700 Received: from [10.50.44.13] (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Mon, 20 Jun 2022 23:31:32 -0700 Message-ID: <00f3eb47-2529-a493-ee67-c0c0219937a3@quicinc.com> Date: Tue, 21 Jun 2022 12:01:29 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH rcu 07/12] rcu: tiny: Record kvfree_call_rcu() call stack for KASAN Content-Language: en-US To: "Paul E. McKenney" , CC: , , , Johannes Berg , Dmitry Vyukov References: <20220620222022.GA3839466@paulmck-ThinkPad-P17-Gen-1> <20220620222032.3839547-7-paulmck@kernel.org> From: Neeraj Upadhyay In-Reply-To: <20220620222032.3839547-7-paulmck@kernel.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On 6/21/2022 3:50 AM, Paul E. McKenney wrote: > From: Johannes Berg > > When running KASAN with Tiny RCU (e.g. under ARCH=um, where > a working KASAN patch is now available), we don't get any > information on the original kfree_rcu() (or similar) caller > when a problem is reported, as Tiny RCU doesn't record this. > > Add the recording, which required pulling kvfree_call_rcu() > out of line for the KASAN case since the recording function > (kasan_record_aux_stack_noalloc) is neither exported, nor > can we include kasan.h into rcutiny.h. > > without KASAN, the patch has no size impact (ARCH=um kernel): > text data bss dec hex filename > 6151515 4423154 33148520 43723189 29b29b5 linux > 6151515 4423154 33148520 43723189 29b29b5 linux + patch > > with KASAN, the impact on my build was minimal: > text data bss dec hex filename > 13915539 7388050 33282304 54585893 340ea25 linux > 13911266 7392114 33282304 54585684 340e954 linux + patch > -4273 +4064 +-0 -209 > > Acked-by: Dmitry Vyukov > Signed-off-by: Johannes Berg > Signed-off-by: Paul E. McKenney > --- > include/linux/rcutiny.h | 11 ++++++++++- > kernel/rcu/tiny.c | 14 ++++++++++++++ > 2 files changed, 24 insertions(+), 1 deletion(-) > > diff --git a/include/linux/rcutiny.h b/include/linux/rcutiny.h > index 5fed476f977f6..d84e13f2c3848 100644 > --- a/include/linux/rcutiny.h > +++ b/include/linux/rcutiny.h > @@ -38,7 +38,7 @@ static inline void synchronize_rcu_expedited(void) > */ > extern void kvfree(const void *addr); > > -static inline void kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func) > +static inline void __kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func) > { > if (head) { > call_rcu(head, func); > @@ -51,6 +51,15 @@ static inline void kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func) > kvfree((void *) func); > } > > +#ifdef CONFIG_KASAN_GENERIC > +void kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func); > +#else > +static inline void kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func) > +{ > + __kvfree_call_rcu(head, func); > +} > +#endif > + > void rcu_qs(void); > > static inline void rcu_softirq_qs(void) > diff --git a/kernel/rcu/tiny.c b/kernel/rcu/tiny.c > index 340b3f8b090d4..58ff3721d975c 100644 > --- a/kernel/rcu/tiny.c > +++ b/kernel/rcu/tiny.c > @@ -217,6 +217,20 @@ bool poll_state_synchronize_rcu(unsigned long oldstate) > } > EXPORT_SYMBOL_GPL(poll_state_synchronize_rcu); > > +#ifdef CONFIG_KASAN_GENERIC > +void kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func) > +{ > + if (head) { > + void *ptr = (void *) head - (unsigned long) func; > + > + kasan_record_aux_stack_noalloc(ptr); > + } For the !head case; similar to Tree RCU's kvfree_call_rcu() implementation, we do not need to record 'ptr' (which will be 'func')? Thanks Neeraj > + > + __kvfree_call_rcu(head, func); > +} > +EXPORT_SYMBOL_GPL(kvfree_call_rcu); > +#endif > + > void __init rcu_init(void) > { > open_softirq(RCU_SOFTIRQ, rcu_process_callbacks);