Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1475891pxf; Fri, 26 Mar 2021 08:23:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2VocNUpFX4Zhb4GosgeWXrP79YzsTKTXMRuZ8Q/NUUzzh0eQtsA/+32lDPZVxbGI6oXHL X-Received: by 2002:a17:906:684b:: with SMTP id a11mr15382059ejs.329.1616772205092; Fri, 26 Mar 2021 08:23:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616772205; cv=none; d=google.com; s=arc-20160816; b=ec+lxK2fLKFxoJ+oDncpjzpjnBqU7h9iIL/VWa5VziYTWBoRVjMSYwrrlBbiHwYiO5 9n39KZhJGz1Z1+1cgSJF6yhxOojbPWOkPlHN+VGccknPpKG8kt/uLliR3sSVAwrvLP3d Pt1ONz96I/OnNaafJ83cIjjPYcsw1bCqkIZywBf/kKW4HeLaqNCrWBTBQWCiEUlolS+m 7LmOsXhSNatvy01obvM6QhlXfWoGxDp3/0IZC2/UuNNz5VaG9bnQMWQVr5SUndeJYoYm IRdHxFAvC1wiVZ7REN0EDnFGhJrUo92fRrHJZCWd8CmpyOti4IaeSDxlYbvEwUv/XsxR GghQ== 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=Qmp+F0418AwvQlnC1o8gzr9PkURFAqbNZKpNnU0rE5w=; b=Ah3baPiFzL5Xl51XZCgxl3j9WtyacoYfwcwgBMhNvgslH1q84hhWUffZulcq5gsKvq 83NjXkaehpmFUzQ7s/qIvatU8S5+GvHzGbTZkd1KSFmYwfMDc2IYv/xnu7dM/qoicexj aJnL63j5aOsjweTMMP+BlEXGQwTO1CA1s4mF28CHswo2+LVB7+B/xgSKVM15wJoYW07K 5TZsVaBqmqBYn48KvYZl1K1Dfpqj9rB1NiscCsAoPMv2Yq8IGaMSylkGRtMXwovI1YWM NA7r8EfGTp7QlyUsO0MloPqvgdKlG2VTdZWC0F3uxtUBk3A19yvsklwcjXe0V5fSJ2Db tw5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="R6Us5JD/"; 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 f11si6857624ejr.284.2021.03.26.08.23.01; Fri, 26 Mar 2021 08:23:25 -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=@infradead.org header.s=desiato.20200630 header.b="R6Us5JD/"; 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 S230135AbhCZPUB (ORCPT + 99 others); Fri, 26 Mar 2021 11:20:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230298AbhCZPT2 (ORCPT ); Fri, 26 Mar 2021 11:19:28 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE7F2C0613AA for ; Fri, 26 Mar 2021 08:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Qmp+F0418AwvQlnC1o8gzr9PkURFAqbNZKpNnU0rE5w=; b=R6Us5JD/hHCwkwlG2iWZqpPSKj T4sPgNZV0BtmPzbZ3YXLquGZtoOC5f08zUguEaqEWWohr04mQvwoPoKC2CHMFI6s2qruo3yNZyM+k TkneEycTgTVvYhO9T5V1LU2pWrQGPVXpjKepQybDWmhO5bB+yhb1q0v7SxXDkZUAGjt+iUdPIXpcv RQ89Fs888/a9LfUZkgC6RFJzcbsr+QDmSbzAOERMy7l8e4V8pl/RB28IyQxGoZyH5lPS6w8Ny3ZxF Wv0oywusG1ik3abtEl3OEPPTtScEwnJDKnhaVjVoOsq0yVlR0ehCzwbVyq7pJbI6kFjDGHzo1WkfJ JeSs3tbw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lPoEz-003sRh-34; Fri, 26 Mar 2021 15:19:13 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id B0DF3980FEF; Fri, 26 Mar 2021 16:19:12 +0100 (CET) Date: Fri, 26 Mar 2021 16:19:12 +0100 From: Peter Zijlstra To: Rasmus Villemoes Cc: Greg KH , 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: <20210326151912.GL4746@worktop.programming.kicks-ass.net> References: <20210326103352.603456266@infradead.org> <20210326103935.183934395@infradead.org> <70594935-18e6-0791-52f9-0448adf37155@rasmusvillemoes.dk> <20210326142230.GJ4746@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 26, 2021 at 03:58:37PM +0100, Rasmus Villemoes wrote: > > kmalloc(len + 2, ...); > > No, because nul-terminating the stuff you pass to > simple_read_from_buffer is pointless cargo-culting. Yeah, read_file_bool > does it, but that's just bogus. Urgh, feel yuck to not have it zero terminated, but if you feel strongly about it I suppose I can make it go away. > > len = strscpy(copy, str, len); > > if (len < 0) > > return len; > > To what end? The only way that could possibly return -EFOO is if the > nul-terminator in str vanished between the strlen() and here, and in > that case you have bigger problems. There are strings in the kernel which we rewrite in most ugly ways, task_struct::comm comes to mind. Best be paranoid. > > Copy-pasta from debugfs_*_bool(). This thing seems to export everything > > and I figured I'd go along with that. > > I thought the convention was not to export anything until the kernel > itself had a (modular) user. That's generally how I feel too. But this really isn't my subsystem so I more or less try to mimmick what I see done there.