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.