From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4B2DC433E0 for ; Fri, 26 Mar 2021 12:58:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90A2D61A0A for ; Fri, 26 Mar 2021 12:58:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230027AbhCZM54 (ORCPT ); Fri, 26 Mar 2021 08:57:56 -0400 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:55481 "EHLO new4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229758AbhCZM5t (ORCPT ); Fri, 26 Mar 2021 08:57:49 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id 4DC1D5804CA; Fri, 26 Mar 2021 08:57:49 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Fri, 26 Mar 2021 08:57:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kroah.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=tDYuafVYEzotN+2vMul5COe5EcS 87TpGB9aummOXYV8=; b=h2oKxvgr9laxdc6WSUEZGupC6smSNtj8vkG+62cTxMC PYP5RwYS+JX62aqsS0Uwl+KDsBZ6N7WpJ3Vjgx1sW5ga7EOruaG9ME0DotQT0kQA 6MO+Z9n14QXTibo03Uzb7NH2JyZKizzaVR9zkscRK4vyZlmDuXylsweRJOSxR/qV 7LHiJF/K3jV7xHWJEigYXPClD+4Z5jZoDIM25XzmedjRBFOYVqxEPHdIoBxEkaBW ZCIn3Db9G+W0Gx9CimxUpg1R9yn9fCBVU0w2L5qIAlTK/NimSMplh+tB2091fS+0 jSGNI+lxBvae0WZjmP9GaA65d/5qzHAIcH8YAk5hg9g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=tDYuaf VYEzotN+2vMul5COe5EcS87TpGB9aummOXYV8=; b=bmhi/2oGUO0sBs5evczbrb ZUpXQJ/LS7i63jECJ6HMeJnguaS1flH3wsynEY9KpFvrrh3ZMbs2ANh8EsW9fFFY LTTV4mLRelk8NC/Z36plMScrOPIIiG8SZ5q+HOE5Wn6I46JD+Y3pHoULewIQ8IFp n1P8lqLIIy2F7Ca1yeLBlUg0G7iyNNShoys3lLz5v0tYDdSEKcqw/9Ueot1bhl/y lgor+riovM1V9r9s+i6KiovB+17380DxalSzkjKB+x0j9tmnLEpsP6kjzPYaEeBY 0qSk1rHAYBTGHCoc6vWIPEA3Oc64XCSVWa0ouYH7PElsO+lKGUbumbN8N5I1Vd/Q == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudehvddggeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpefirhgvghcu mffjuceoghhrvghgsehkrhhorghhrdgtohhmqeenucggtffrrghtthgvrhhnpeevueehje fgfffgiedvudekvdektdelleelgefhleejieeugeegveeuuddukedvteenucfkphepkeef rdekiedrjeegrdeigeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehgrhgvgheskhhrohgrhhdrtghomh X-ME-Proxy: Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) by mail.messagingengine.com (Postfix) with ESMTPA id 5531124005D; Fri, 26 Mar 2021 08:57:47 -0400 (EDT) Date: Fri, 26 Mar 2021 13:57:44 +0100 From: Greg KH To: Rasmus Villemoes Cc: Peter Zijlstra , mingo@kernel.org, mgorman@suse.de, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, bristot@redhat.com, joshdon@google.com, valentin.schneider@arm.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 6/9] debugfs: Implement debugfs_create_str() Message-ID: References: <20210326103352.603456266@infradead.org> <20210326103935.183934395@infradead.org> <70594935-18e6-0791-52f9-0448adf37155@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <70594935-18e6-0791-52f9-0448adf37155@rasmusvillemoes.dk> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 26, 2021 at 01:53:59PM +0100, Rasmus Villemoes wrote: > On 26/03/2021 12.38, Peter Zijlstra wrote: > > > Implement debugfs_create_str() to easily display names and such in > > debugfs. > > Patches 7-9 don't seem to add any users of this. What's it for precisely? It's used in patch 7, look close :) > > > + > > +again: > > + rcu_read_lock(); > > + str = rcu_dereference(*(char **)file->private_data); > > + len = strlen(str) + 1; > > + > > + if (!copy || copy_len < len) { > > + rcu_read_unlock(); > > + kfree(copy); > > + copy = kmalloc(len + 1, GFP_KERNEL); > > + if (!copy) { > > + debugfs_file_put(dentry); > > + return -ENOMEM; > > + } > > + copy_len = len; > > + goto again; > > + } > > + > > + strncpy(copy, str, len); > > + copy[len] = '\n'; > > + copy[len+1] = '\0'; > > + rcu_read_unlock(); > > As noted (accidentally off-list), this is broken. I think you want this > on top > > - len = strlen(str) + 1; > + len = strlen(str); > > - strncpy(copy, str, len); > + memcpy(copy, str, len); > copy[len] = '\n'; > - copy[len+1] = '\0'; > > > +EXPORT_SYMBOL_GPL(debugfs_read_file_str); > > Why? Because there is a user of it? Yes, it's not in a module, but to make it easy, might as well export it now. thanks, greg k-h