Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1324162pxf; Fri, 26 Mar 2021 05:59:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzC+gD2vWDC7cqHzbGiUxFTEwkO8k6LHFox+nrrqft7xILcFWz8MOMfUALbVwhVlf9bDR8D X-Received: by 2002:a05:6402:3c7:: with SMTP id t7mr15010080edw.196.1616763587385; Fri, 26 Mar 2021 05:59:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616763587; cv=none; d=google.com; s=arc-20160816; b=00ll5Hn/AeTyaRDbf7lZiDfvoLSCz0sE9pAvelvPqJKvCZ27ZJs8o0FaYnzhl6vJyv ClyCS/YfhNe7qyh5pbTcLQaWPTRznhykNHOEorhfZsUGn+h3YM5XdnpyVmf/o25pWeS6 jvPeFDmfHo2gHiBgx8+77ct2I8elMqHwb+J2RQZ06dJNFSv8q+pCfIMkaWUPMV+ij7Ma 7I0aA2y8bqiHUFIdpi0QYb02ZcNSA8kY2zWU54oWiMTvVmK5dqnD3a4dgjTU5oh8x05k 2/qNy99vTaNj5EKCGu+zpKJhwLWprS7spwc9zKwCzgYBO3y3k6tJOfwEnCJeb78kciX3 msxQ== 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 :dkim-signature; bh=tDYuafVYEzotN+2vMul5COe5EcS87TpGB9aummOXYV8=; b=V79sTs3dXLRTHt03hCWjIxQZxTNJbnPNKp/PNjchVStdm3oM+tbwOiDbrTeyFxXbvb XGMwLJPMRbhkN+1kODwZhfKoIUB9cB4vOn27LbYBj9l/lcyH0WVRT4xu4BUKKSmqPlhv 1Ilqef5cLcqvOnUBgV+/kqy/6dxaA18UPdz77k7t6pdn6Al5YoR9WCzumEBbRlJ7t6Yy cRTtmHdRhNWogcB4xUvOgzVPQY/RvuKiZ2iPwtmDbFovnDjtBQSI5vemnOvIVk0GhrEp vcwiEXSKFnt4zsMXDJs2jGQSHTGY20YKZlBoEGXNXmOt6dniX8o1xxB+tYf8ZMZA4GPw hkWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kroah.com header.s=fm3 header.b=h2oKxvgr; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="bmhi/2oG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c14si7796191edn.523.2021.03.26.05.59.24; Fri, 26 Mar 2021 05:59:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kroah.com header.s=fm3 header.b=h2oKxvgr; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="bmhi/2oG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229986AbhCZM5z (ORCPT + 99 others); Fri, 26 Mar 2021 08:57:55 -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