Re: [PATCH 0/4] um: Assorted console related fixes

Glenn Washburn
2022-06-06T23:16:36Z

On Mon, 4 Apr 2022 23:41:29 +0200
Richard Weinberger <richard.weinberger@gmail.com> wrote:

> Glenn,
>
> On Thu, Mar 10, 2022 at 7:22 PM Glenn Washburn
> <development@efficientek.com> wrote:
> >
> > On Wed, 9 Mar 2022 09:35:02 +0100 (CET)
> > Richard Weinberger <richard@nod.at> wrote:
> >
> > > ----- Ursprüngliche Mail -----
> > > >> This series fixes the console exit code to make sure UML
> > > >> undoes everything it changed on the host side.
> > > >
> > > > I gave this a run hoping it would fix the issues I'm seeing with the console
> > > > getting messed up when UML exits via halt in the guest. Echo is turned off
> > > > and looks like carriage return doesn't work either. I'm using "reset" to get
> > > > the terminal back to its previous state. Unfortunately this patch series did
> > > > not fix this issue.
> > > >
> > > > I'm not saying that these aren't valid fixes. But it does appear that these
> > > > changes don't make sure that "everything" changed on the host side is undone.
> > >
> > > So when you compare "stty -a" before and after the damange you still see differences?
> > > Please also compare the flags of /proc/$$/fdinfo/{0,1,2}
> >
> > Here's a diff of the before and after:
> > -- /tmp/uml-console.before.out 2022-03-10 18:12:54.049171650 +0000
> > +++ /tmp/uml-console.after.out 2022-03-10 18:13:20.711630281 +0000
> > @@ -3,20 +3,20 @@
> > eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
> > werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
> > -parenb -parodd -cmspar cs8 hupcl -cstopb cread -clocal -crtscts
> > --ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
> > +-ignbrk -brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff
> > -iuclc -ixany imaxbel -iutf8
> > -opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
> > -isig icanon -iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
> > +-opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
> > +-isig -icanon -iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
> > echoctl echoke -flusho -extproc
> > /proc/3383323/fdinfo/0:1:pos: 0
> > -/proc/3383323/fdinfo/0:2:flags: 0120002
> > +/proc/3383323/fdinfo/0:2:flags: 0124002
> > /proc/3383323/fdinfo/0:3:mnt_id: 6104
> > /proc/3383323/fdinfo/0:4:ino: 24
> > /proc/3383323/fdinfo/1:1:pos: 0
> > -/proc/3383323/fdinfo/1:2:flags: 0120002
> > +/proc/3383323/fdinfo/1:2:flags: 0124002
> > /proc/3383323/fdinfo/1:3:mnt_id: 6104
> > /proc/3383323/fdinfo/1:4:ino: 24
> > /proc/3383323/fdinfo/2:1:pos: 0
> > -/proc/3383323/fdinfo/2:2:flags: 0120002
> > +/proc/3383323/fdinfo/2:2:flags: 0124002
> > /proc/3383323/fdinfo/2:3:mnt_id: 6104
> > /proc/3383323/fdinfo/2:4:ino: 24
> >
> > It looks like these were not reset: brkin icrnl ixon opost isig icanon echo
> >
> > Originally I was applying this patch series to 5.16.12 and seeing this issue.
> > But I this output is from applying the patch series to 5.17-rc7, if that matters. Thanks for looking t this.
>
> Hmm. Looks like the cleanup function is never called.
> Can you verify whether uml_console_exit() runs at exit time?

Sorry about the delay. I don't think that uml_console_exit() is getting
run. I'm testing this by running a UML instance which has been compiled
with -ggdb3. Then attach to the running process via GDB. Set a
breakpoint on uml_console_exit(), then do a shutdown/halt (syscall
reboot(0x4321fedc)). GDB says that the process was terminated with
SIGKILL, which I'm guessing is why uml_console_exit() is not run.

Glenn