Re: [PATCH RESEND v2 14/23] proc: let procfs copy in writes before pinning the entry

Started by Christian Brauner on Nov 7, 2026 · 6 messages from 4 authors · Last reply Nov 16, 2026

open the first message on its own page

Message details and related content
On Thu, Nov 05, 2026 at 11:07:32AM +0100, Geert Uytterhoeven wrote:
quoted
+       ssize_t (*proc_write_buf)(struct file *, char *, size_t, loff_t *);
"const char *"?
I prototyped this to have a detailed reply. It's not worth it.

* The buffer is the entry's private copy.
  procfs creates the copy for this specific call and frees it
  afterwards.

  A bunch of handlers modify the buffer in place and it's documented as
  allowed:

  - afs_proc_cells_write()
  - afs_proc_sysname_write
  - a chunk of the sunrpc cache channel ->cache_parse() implementations
  - thinkpad_acpi's ->write() methods
  - SCSI devinfo file
  - dyndbg
  - cio_ignore
  - the pseries ofdt parsers
  - two more hand the buffer to a char * interface:
    - the SCSI host ->write_info()
    - simple_strtoul() in proc_scsi_write()
  - four strip a trailing newline in place

All ways to make that work suck.

(1) Copy in the handler. That means eight kmemdup_nul()s and a
    kvmemdup() for every nfs downcall.
    IOW the copy this series just removed comes back as a copy of a
    copy which is not acceptable.

(2) Make the parsers work on spans which also sucks and doesn't solve
    all of them.

(3) Leave the buffer writable. Costs nothing, nobody else can see it.

So (3) I think char * stays.
While at it, I think it would be good to use this conversion as an
opportunity to replace "char *" by "void *", which will probably let
you drop several casts from users.
So I tried that too. The thing is it drops exactly one u8 * cast in
ntfs3's label write. And to get this done we need to introduce a whole
range of local char *foo = arg assignments. So I decided against this.
It just doesn't add value.

Thanks for taking a look!
Message details and related content
On Sat, 7 Nov 2026 10:48:35 +0100
Christian Brauner [off-list ref] wrote:
quoted
While at it, I think it would be good to use this conversion as an
opportunity to replace "char *" by "void *", which will probably let
you drop several casts from users.  
So I tried that too. The thing is it drops exactly one u8 * cast in
ntfs3's label write. 
Since char is now unsigned that one isn't even needed...

David
Message details and related content
On Sun, 8 Nov 2026, David Laight wrote:
quoted
quoted
While at it, I think it would be good to use this conversion as an
opportunity to replace "char *" by "void *", which will probably let
you drop several casts from users.  
So I tried that too. The thing is it drops exactly one u8 * cast in
ntfs3's label write. 
Since char is now unsigned that one isn't even needed...
 Please excuse me missing the context, but what circumstances does your 
claim refer to?

  Maciej
Message details and related content
On Mon, 9 Nov 2026 05:05:57 +0000 (GMT)
"Maciej W. Rozycki" [off-list ref] wrote:
On Sun, 8 Nov 2026, David Laight wrote:
quoted
quoted
quoted
While at it, I think it would be good to use this conversion as an
opportunity to replace "char *" by "void *", which will probably let
you drop several casts from users.    
So I tried that too. The thing is it drops exactly one u8 * cast in
ntfs3's label write.   
Since char is now unsigned that one isn't even needed...  
 Please excuse me missing the context, but what circumstances does your 
claim refer to?
Just that the cast would have to be:
	u8 *foo = (u8 *)bar;
where 'bar' is 'char *', and I don't think you need a cast there when
char is unsigned.

David
 
  Maciej
Message details and related content
On Mon, 9 Nov 2026 at 13:46, David Laight [off-list ref] wrote:
Just that the cast would have to be:
        u8 *foo = (u8 *)bar;
where 'bar' is 'char *', and I don't think you need a cast there when
char is unsigned.
.. and just to clarify: 'char' is always unsigned in the kernel on all
architectures since commit 3bc753c06dd0 ("kbuild: treat char as always
unsigned") back four years ago...

            Linus
Message details and related content
On Mon, 9 Nov 2026, Linus Torvalds wrote:
quoted
Just that the cast would have to be:
        u8 *foo = (u8 *)bar;
where 'bar' is 'char *', and I don't think you need a cast there when
char is unsigned.
.. and just to clarify: 'char' is always unsigned in the kernel on all
architectures since commit 3bc753c06dd0 ("kbuild: treat char as always
unsigned") back four years ago...
 Thanks, yes, that's the piece of the context I was missing.  I've since
actually come across this commit while investigating which Linux ports 
have plain `char' signed in the psABI (MIPS for sure).

  Maciej
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help