Messages in this thread | | | Date | Fri, 26 Mar 2021 16:19:12 +0100 | From | Peter Zijlstra <> | Subject | Re: [PATCH v2 6/9] debugfs: Implement debugfs_create_str() |
| |
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.
| |