public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* proc_lseek backport request
@ 2023-08-17  9:22 t.martitz
  2023-08-17 14:43 ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: t.martitz @ 2023-08-17  9:22 UTC (permalink / raw)
  To: stable; +Cc: Al Viro

Dear stable team,

I'm asking that 

commit 3f61631d47f1 ("take care to handle NULL ->proc_lseek()")

gets backported to the stable and LTS kernels down to 5.10.

Background:
We are in the process of upgrading our kernels. One target kernel
is based on 5.15 LTS.

Here we found that, if proc file drivers do not implement proc_lseek,
user space crashes easily, because various library routines internally
perform lseek(2). The crash happens in proc_reg_llseek, where it
wants to jump to a NULL pointer.

We could, arguably, fix these drivers to use ".proc_lseek = no_llseek".
But this doesn't seem like a worthwhile path forward, considering that
latest Linux kernels (including 6.1 LTS) allow proc_lseek == NULL again 
and *remove* no_lseek. Essentially, on HEAD, it's best practice to leave 
proc_lseek == NULL.
Therefore, I ask that the above procfs fix gets backported so that our
drivers can work across all kernel versions, including latest 6.x.

I checked that this commit applies and works as expected on a board that
runs Linux 5.15, and the observed crash goes away.

Furthermore, I investigated that the fix applies to older LTS kernels, down
to 5.10. The lseek(2) path uses vfs_llseek() which checks for FMODE_LSEEK. This
has been like that forever since the initial git import. However, 5.4 LTS and 
older kernels do not have "struct proc_ops".

Thank you in advance.

Best regards,
Thomas Martitz

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-21 13:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-17  9:22 proc_lseek backport request t.martitz
2023-08-17 14:43 ` Greg KH
2023-08-17 15:42   ` David Laight
2023-08-17 15:59     ` 'Greg KH'
2023-08-21  6:28   ` t.martitz
2023-08-21 13:17     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox