Re: [PATCH] lib/vsprintf: Validate sleepable context during restrictred pointer formatting
From: Sebastian Andrzej Siewior
Date: Thu Mar 19 2026 - 04:19:13 EST
On 2026-03-18 16:10:24 [+0100], Thomas Weißschuh wrote:
> That was my plan. My current idea uses a raw 'struct lockdep_map'
> without a dummy spinlock, as the spinlock would never be used anyways.
> But if the dummy spinlock would be better for some reason, let's use that.
just lockdep is fine. It is just annotation & verification at runtime,
no actual locking is needed/ intended.
> > > > than %pK. According to commit 312b4e226951f ("vsprintf: check real
> > > > user/group id for %pK") it is temporary as of 2013. There should be a
> > > > check at open time instead.
> > >
> > > Doing the check at open time requires some place to store the result
> > > of it. The users of %pK I looked at all reused their core datastructures
> > > as state in seq_file, so finding space for the result from open time
> > > would require some non-trivial changes to them.
> >
> > You could go for the easy solution and return early with -EACCES or so.
> > That was the intention according to my understanding.
>
> My understanding is different. The file should be readable for everybody.
> But the actual contents depend on the user reading it. The clean solution
> would be to check the user during open() and decide once if the pointers
> should be printed raw/hashed/zeroed out.
>
> The fact that even 13 years later there are no helpers whatsoever for
> users to do the checks at open() time and later do the formatting,
> probably didn't help the adoption of that scheme.
I don't recall needing ever pointer for other reasons than debugging.
> Thomas
Sebastian