Commit 2ce3d28
proc: fix missing pde_set_flags() for net proc files
To avoid potential UAF issues during module removal races, we use
pde_set_flags() to save proc_ops flags in PDE itself before
proc_register(), and then use pde_has_proc_*() helpers instead of directly
dereferencing pde->proc_ops->*.
However, the pde_set_flags() call was missing when creating net related
proc files. This omission caused incorrect behavior which FMODE_LSEEK was
being cleared inappropriately in proc_reg_open() for net proc files. Lars
reported it in this link[1].
Fix this by ensuring pde_set_flags() is called when register proc entry,
and add NULL check for proc_ops in pde_set_flags().
[[email protected]: stash pde->proc_ops in a local const variable, per Christian]
Link: https://lkml.kernel.org/r/[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Link: https://lore.kernel.org/all/[email protected]/ [1]
Fixes: ff7ec8d ("proc: use the same treatment to check proc_lseek as ones for proc_read_iter et.al")
Signed-off-by: wangzijie <[email protected]>
Reported-by: Lars Wendler <[email protected]>
Tested-by: Stefano Brivio <[email protected]>
Tested-by: Petr Vaněk <[email protected]>
Tested by: Lars Wendler <[email protected]>
Cc: Alexei Starovoitov <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: Al Viro <[email protected]>
Cc: "Edgecombe, Rick P" <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Jiri Slaby <[email protected]>
Cc: Kirill A. Shutemov <[email protected]>
Cc: wangzijie <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>1 parent c357688 commit 2ce3d28
1 file changed
+21
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
370 | 389 | | |
371 | 390 | | |
372 | 391 | | |
373 | 392 | | |
374 | 393 | | |
375 | 394 | | |
376 | 395 | | |
| 396 | + | |
| 397 | + | |
377 | 398 | | |
378 | 399 | | |
379 | 400 | | |
| |||
561 | 582 | | |
562 | 583 | | |
563 | 584 | | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | 585 | | |
579 | 586 | | |
580 | 587 | | |
| |||
585 | 592 | | |
586 | 593 | | |
587 | 594 | | |
588 | | - | |
589 | 595 | | |
590 | 596 | | |
591 | 597 | | |
| |||
636 | 642 | | |
637 | 643 | | |
638 | 644 | | |
639 | | - | |
640 | 645 | | |
641 | 646 | | |
642 | 647 | | |
| |||
667 | 672 | | |
668 | 673 | | |
669 | 674 | | |
670 | | - | |
671 | 675 | | |
672 | 676 | | |
673 | 677 | | |
| |||
0 commit comments