Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp953273rwd; Tue, 16 May 2023 09:42:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5YJtaMFBqLsVSbKL3vOMjc5FDzQAsg/+8YS2D36zq8FFdONuOeh3Q2bKYsA8t5b2xTifdp X-Received: by 2002:a17:903:32c7:b0:1ac:7345:f254 with SMTP id i7-20020a17090332c700b001ac7345f254mr43361945plr.33.1684255353360; Tue, 16 May 2023 09:42:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684255353; cv=none; d=google.com; s=arc-20160816; b=gVL64CQJnFgajeNbmWZVMEOKpwSWSakCXN8XgLffosCfbaMFhFeW4jX8tt3UOvs0sT uD6USguRhceQttTLybL3V6fSr131UoCSvyj/OK6qOc/o/6k9c1UadVU0eRmw5H6HZZfW TC8yTU8psw3dFVXv7reyZ6KMhgLi+/HQoAgsB/a9dmsfj7dubQyHzaP6MuTW2GngCRxc DmcIkVZcKKsyi4ap08max+BZ7FxeL61+UntEP4NO/YSVwy5Mu1eAd0C1wOYNdDR0xbSK NHwTD6GTigP7ne+TRAGkjRe5/HPE2sjXO4YvkGnPNJcv+CtvJXZxIFz+hGNHcXbtO/9j QORw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=dprMpfZ1XbGgOpnYwJdLrlowB+f/MPcYz6dQUSgaUVE=; b=xWp4lx2OZL8NqmUmBxcg26byJJtsJGuzX0u6Qz8znO9V+7VqhpGYAqj9iwySj+QAM6 U1xEsxag2TYn5clNwyJiF/vG/noT6UwFEmQWVAWM4MqDrmGRc3NOS8ElNbEo4PyaqqYB c51Oqtc0tfKcVUgWaS5EF8UoLXAk6LbiiAzJR2G+jsjlgACjqltK9sppxDiEKXHg7FGh cpX+sy2swTZiI6K7YvEZUyXqRmFmO7LI2h+A2n9UxkXHMw2P9z01UgwSN12UYc27lHgD Yl+1hZNc4/Ukgxk7lNNcda3NdCPdo16h/mZhRJw290+HDY4uW513pClVDRGo9HdiHNUU smTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VaVc3A73; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c16-20020a170902b69000b001aafe3f40a7si18235323pls.579.2023.05.16.09.42.19; Tue, 16 May 2023 09:42:33 -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=@linuxfoundation.org header.s=korg header.b=VaVc3A73; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231192AbjEPQf5 (ORCPT + 99 others); Tue, 16 May 2023 12:35:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230504AbjEPQfp (ORCPT ); Tue, 16 May 2023 12:35:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B30AD199C for ; Tue, 16 May 2023 09:35:29 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 513D863C45 for ; Tue, 16 May 2023 16:35:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66805C433D2; Tue, 16 May 2023 16:35:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1684254928; bh=pzrphtg3UBaTAewESas3zBzhgLY1SwFmbsXEBG4l5RM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VaVc3A73M2+xJnn6r1nffgQwJzpMkUBkNjz0nnnB7DJniaf7oBsKC3AnIY8GuCeMC u/QZvXNhYT7Z8FO9TkyCfibxG7NMtj0Add+UpNJCdw7aDJubOCJ/EBOSVj26vxJvrW Qkn8Wn6zhC6m8xOC/lrm2XWo8/ekUA9snV06YoP4= Date: Tue, 16 May 2023 18:35:25 +0200 From: Greg KH To: Richard Fitzgerald Cc: rafael@kernel.org, linux-kernel@vger.kernel.org, patches@opensource.cirrus.com Subject: Re: [PATCH 3/5] debugfs: Update debugfs_create_str() kerneldoc to warn about pointer race Message-ID: <2023051607-trial-worrisome-87df@gregkh> References: <20230516160753.32317-1-rf@opensource.cirrus.com> <20230516160753.32317-4-rf@opensource.cirrus.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230516160753.32317-4-rf@opensource.cirrus.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Tue, May 16, 2023 at 05:07:51PM +0100, Richard Fitzgerald wrote: > Add a warning to the debugfs_create_str() kerneldoc that the char * pointer > value must not change after the function returns, because of a race with > debugfs_read_file_str() accessing the pointer. > > The only safe case is a change from NULL to non-NULL because in that case > debugfs_read_file_str() will see either the NULL or the valid pointer. > > Signed-off-by: Richard Fitzgerald > --- > fs/debugfs/file.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c > index 0c039a3d9a42..77794871f26d 100644 > --- a/fs/debugfs/file.c > +++ b/fs/debugfs/file.c > @@ -938,11 +938,18 @@ static const struct file_operations fops_str_wo = { > * directory dentry if set. If this parameter is %NULL, then the > * file will be created in the root of the debugfs filesystem. > * @value: a pointer to the variable that the file should read to and write > - * from. > + * from. The char* pointer must not change, except from NULL to > + * non-NULL. This feels odd. Why wouldn't you want to change the string value? Or why would you? And why is this one-way transition ok? Given that this is only used internally, why is it exported? thanks, greg k-h