linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] misc/fsck.c: Processes may kill other processes.
@ 2022-09-29  7:39 zhanchengbin
  2022-09-29 11:28 ` Lukas Czerner
  0 siblings, 1 reply; 7+ messages in thread
From: zhanchengbin @ 2022-09-29  7:39 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: linux-ext4, liuzhiqiang26, linfeilong

Hi Tytso,
I find a error in misc/fsck.c, if run the fsck -N command, processes
don't execute, just show what would be done. However, the pid whose
value is -1 is added to the instance_list list in the execute
function,if the kill_all function is called later, kill(-1, signum)
is executed, Signals are sent to all processes except the number one
process and itself. Other processes will be killed if they use the
default signal processing function.

execute:
     if (noexecute)
         pid = -1;
     inst->pid = pid;
     // Find the end of the list, so we add the instance on at the end.

kill_all:
     for (inst = instance_list; inst; inst = inst->next) {
         kill(inst->pid, signum);
     }

misc/fsck.c:
main:
     ->PRS
         case 'N':
             noexecute++;
     for (num_devices) {
         if (cancel_requested) {
             ->kill_all(SIGTERM);
         }
         ->fsck_device
             ->execute
     }

(gdb) bt
#0  execute (type=<optimized out>, type@entry=0x412cd0 "ext4", 
device=0x412b00 "/root/a.img", mntpt=<optimized out>, 
interactive=interactive@entry=1) at fsck.c:523
#1  0x0000000000404959 in fsck_device (fs=fs@entry=0x412ac0, 
interactive=interactive@entry=1) at fsck.c:727
#2  0x0000000000402704 in main (argc=<optimized out>, argv=<optimized 
out>) at fsck.c:1333
(gdb) p inst->pid
$7 = -1

regards,
Zhan Chengbin

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

end of thread, other threads:[~2022-10-10  9:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-29  7:39 [bug report] misc/fsck.c: Processes may kill other processes zhanchengbin
2022-09-29 11:28 ` Lukas Czerner
2022-09-30  1:42   ` zhanchengbin
2022-09-30  7:20     ` Lukas Czerner
2022-10-04 22:18       ` Darrick J. Wong
2022-10-10  8:09       ` Karel Zak
2022-10-10  9:26         ` zhanchengbin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).