Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2545921pxf; Sat, 27 Mar 2021 15:29:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5SPZxJlNrtOg9qadoBhrpDSBaDNTHE4DlP3LhSdRAlYoJd/+SfVqzsW76w8sHm3+kacuQ X-Received: by 2002:a17:906:e48:: with SMTP id q8mr22424863eji.84.1616884175858; Sat, 27 Mar 2021 15:29:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616884175; cv=none; d=google.com; s=arc-20160816; b=tXU/b6hKjTVHxlREggcZE1rRdBPikLZMkiHH/UyKGVrY5kRH9GQ1VkicOWBhEw/lHl PiwlgyyomMb7F6WTQx9znh4GqSOAIea0zeCyjX65Cu/XDYP8EJ4dY9ynxw6sfQTjGZAj Klc1eP6WiR7vpk9PP+DR+KP/7vHY8W6aU8WEMJCjquFwnAO9tAURoeR7yYyAeVgRX2P8 tDNk/TddbVVWpPfXGYdgy4F0/BJLtwMo0QNaNRyKSQp5SJJWWqYNyhfG3Jc8+oMViaM9 JfiT/MeAAWOEVpOZA6AJtpVBefJAa/WmlOlE1NnFhc/zvXyvwRQajsiVVgEg9wovj1yQ EEgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=iin7CH/40I5efhIZ5Eac+fU1CGekjIZeubEsW5MJK6o=; b=D4B1Mx1Ii939WK3Xde3vR9FssU3/KdTk3A/dNi2Oj+S7lS+GhCR3ayV9zHRATv0o3b 2IWomTINw/8AGaaF1FQT0ASeZbY52yibRMjpDkXN8ntVewpcJenB0Z7szuAmDkE04Tse YCNG4VM9baZK9bnGiiIeuz+1s7WjZIPIxo6jkxPcjrrdv1+uHbVwcxd1VkRgscCUr84A XHnI3AM8QfG4MeDpNd6ItVvrY1EXF3dMbi12FnEH4atVfs75RJ8GXtIjPtydZao2BQZE MIY4GklG2gvg0yQBOkTDueEUyIpSqLIew57J097iIDCmsojYvG+7YyaJN4EGfG8A9NvS E0uA== ARC-Authentication-Results: i=1; mx.google.com; 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 n23si10033746ejr.458.2021.03.27.15.29.13; Sat, 27 Mar 2021 15:29:35 -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; 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 S230500AbhC0WZ3 (ORCPT + 99 others); Sat, 27 Mar 2021 18:25:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230176AbhC0WZD (ORCPT ); Sat, 27 Mar 2021 18:25:03 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AD2AC0613B1 for ; Sat, 27 Mar 2021 15:25:03 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94 #2 (Red Hat Linux)) id 1lQHML-000JpF-KS; Sat, 27 Mar 2021 22:24:45 +0000 Date: Sat, 27 Mar 2021 22:24:45 +0000 From: Al Viro To: Peter Zijlstra Cc: 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, greg@kroah.com Subject: Re: [PATCH 6/9] debugfs: Implement debugfs_create_str() Message-ID: References: <20210326103352.603456266@infradead.org> <20210326103935.183934395@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210326103935.183934395@infradead.org> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 26, 2021 at 11:33:58AM +0100, Peter Zijlstra wrote: > +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(); *Ow* If the string can't change under you, what is RCU use about? And if it can, any use of string functions is asking for serious trouble; they are *not* guaranteed to be safe when any of the strings involved might be modified under them.