lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YF3aSJ7OYiCpWsl8@kroah.com>
Date:   Fri, 26 Mar 2021 13:57:44 +0100
From:   Greg KH <greg@...ah.com>
To:     Rasmus Villemoes <linux@...musvillemoes.dk>
Cc:     Peter Zijlstra <peterz@...radead.org>, mingo@...nel.org,
        mgorman@...e.de, juri.lelli@...hat.com, vincent.guittot@...aro.org,
        dietmar.eggemann@....com, rostedt@...dmis.org, bsegall@...gle.com,
        bristot@...hat.com, joshdon@...gle.com, valentin.schneider@....com,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 6/9] debugfs: Implement debugfs_create_str()

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ