All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean-Christian de Rivaz <jc@eclis.ch>
To: Thomas Osterried <thomas@osterried.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>
Cc: "Peter Hurley" <peter@hurleysoftware.com>,
	"David Ranch" <dranch@trinnet.net>,
	"Ralf Bächle DL5RB" <ralf@linux-mips.org>,
	linux-hams@trinnet.net, linux-hams@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: Force mkiss to reset the line discipline when serial device is removed
Date: Fri, 02 Oct 2015 19:25:27 +0200	[thread overview]
Message-ID: <560EBE07.70801@eclis.ch> (raw)
In-Reply-To: <560E8B1C.9030209@eclis.ch>

Le 02. 10. 15 15:48, Jean-Christian de Rivaz a écrit :
> Le 02. 10. 15 12:35, Thomas Osterried a écrit :
>
>> I also wonder why userspace processes like kissattach do not get a 
>> signal by the kernel, indicating that the filedescriptor is not valid 
>> anymore.
>> Who’s job would it be to signal, the serial driver’s (slip, ppp, 
>> mkiss, ..), or ldisc’s?
>
> It's a complete other problem, not kernel related. The safety of the 
> kernel cannot depend on a user application closing a file descriptor. 
> Even if the user application close his file descriptor, process 
> scheduling can make this delayed long enough to let's a packet reach 
> the parasitic uninitialized interface and completely crash the system. 
> This will at best only reduce the race window but do nothing to fix 
> the real bug. That said, kissattach uses a while (1) { sleep(); } loop 
> that can be cheaply replaced by a single old select() waiting on the 
> file descriptor. My understanding is that after the the AX25 
> discipline is in place the only event that can happen is that the 
> descriptor is to be closed. I will test a kissattach patch for this.
>
> AFAIK tty_ldisc_hangup() already signal EOF to the file descriptor 
> owner with these lines:
>
>         wake_up_interruptible_poll(&tty->write_wait, POLLOUT);
>         wake_up_interruptible_poll(&tty->read_wait, POLLIN);
>

I was completely wrong on this. The kissattach application get no event 
at all. I tried with select() and poll().

You are right, something is missing in the kernel to notify EOF in the 
descriptor of a removed serial device when at least the N_AX25 line 
discipline is used. The EOF is notified correctly at least in the case 
of the N_TTY line discipline.

So your question make sense: who must send the EOF ? Maybe it's the line 
discipline code.

Greg, Jiri, can you give some hint ?

Best Regards,
Jean-Christian de Rivaz

--
To unsubscribe from this list: send the line "unsubscribe linux-hams" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Jean-Christian de Rivaz <jc@eclis.ch>
To: Thomas Osterried <thomas@osterried.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>
Cc: "Peter Hurley" <peter@hurleysoftware.com>,
	"David Ranch" <dranch@trinnet.net>,
	"Ralf Bächle DL5RB" <ralf@linux-mips.org>,
	linux-hams@trinnet.net, linux-hams@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: Force mkiss to reset the line discipline when serial device is removed
Date: Fri, 02 Oct 2015 19:25:27 +0200	[thread overview]
Message-ID: <560EBE07.70801@eclis.ch> (raw)
In-Reply-To: <560E8B1C.9030209@eclis.ch>

Le 02. 10. 15 15:48, Jean-Christian de Rivaz a écrit :
> Le 02. 10. 15 12:35, Thomas Osterried a écrit :
>
>> I also wonder why userspace processes like kissattach do not get a 
>> signal by the kernel, indicating that the filedescriptor is not valid 
>> anymore.
>> Who’s job would it be to signal, the serial driver’s (slip, ppp, 
>> mkiss, ..), or ldisc’s?
>
> It's a complete other problem, not kernel related. The safety of the 
> kernel cannot depend on a user application closing a file descriptor. 
> Even if the user application close his file descriptor, process 
> scheduling can make this delayed long enough to let's a packet reach 
> the parasitic uninitialized interface and completely crash the system. 
> This will at best only reduce the race window but do nothing to fix 
> the real bug. That said, kissattach uses a while (1) { sleep(); } loop 
> that can be cheaply replaced by a single old select() waiting on the 
> file descriptor. My understanding is that after the the AX25 
> discipline is in place the only event that can happen is that the 
> descriptor is to be closed. I will test a kissattach patch for this.
>
> AFAIK tty_ldisc_hangup() already signal EOF to the file descriptor 
> owner with these lines:
>
>         wake_up_interruptible_poll(&tty->write_wait, POLLOUT);
>         wake_up_interruptible_poll(&tty->read_wait, POLLIN);
>

I was completely wrong on this. The kissattach application get no event 
at all. I tried with select() and poll().

You are right, something is missing in the kernel to notify EOF in the 
descriptor of a removed serial device when at least the N_AX25 line 
discipline is used. The EOF is notified correctly at least in the case 
of the N_TTY line discipline.

So your question make sense: who must send the EOF ? Maybe it's the line 
discipline code.

Greg, Jiri, can you give some hint ?

Best Regards,
Jean-Christian de Rivaz


  reply	other threads:[~2015-10-02 17:25 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-25 17:21 AX25 mkiss interface not deleted when the serial port is removed Jean-Christian de Rivaz
2015-09-28 20:06 ` Jean-Christian de Rivaz
2015-09-28 23:13   ` Jean-Christian de Rivaz
2015-09-29  2:13     ` David Ranch
2015-09-29 15:31 ` Ralf Baechle DL5RB
2015-09-29 15:46   ` Jean-Christian de Rivaz
2015-09-29 16:49   ` David Ranch
2015-09-29 17:14     ` Ralf Baechle
2015-09-30  0:29   ` Jean-Christian de Rivaz
2015-09-30 20:22     ` Thomas Osterried
2015-09-30 23:04       ` Jean-Christian de Rivaz
2015-10-01  2:56         ` [PATCH 1/1] Force mkiss to reset the line discipline when serial device " jc
2015-10-01  7:31           ` Ralf Baechle
2015-10-01  9:18             ` [PATCH v2 " Jean-Christian de Rivaz
2015-10-01 16:56               ` Jean-Christian de Rivaz
2015-10-01 22:57                 ` Peter Hurley
2015-10-02  8:30                   ` Jean-Christian de Rivaz
2015-10-02  8:30                     ` Jean-Christian de Rivaz
2015-10-02 10:35                     ` Thomas Osterried
2015-10-02 10:35                       ` Thomas Osterried
2015-10-02 13:48                       ` Jean-Christian de Rivaz
2015-10-02 17:25                         ` Jean-Christian de Rivaz [this message]
2015-10-02 17:25                           ` Jean-Christian de Rivaz
2015-10-02 21:46                           ` [PATCH 1/1] Add poll method to mkiss let notify hangup to the user process Jean-Christian de Rivaz
2015-10-03  0:29                             ` David Ranch
2015-10-03  1:02                               ` Jean-Christian de Rivaz
2016-02-11 19:14                               ` Thomas Osterried
2015-10-02 21:40                         ` [PATCH 1/1] Close the file descriptor and exit when the kernel notice hangup Jean-Christian de Rivaz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=560EBE07.70801@eclis.ch \
    --to=jc@eclis.ch \
    --cc=dranch@trinnet.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-hams@trinnet.net \
    --cc=linux-hams@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter@hurleysoftware.com \
    --cc=ralf@linux-mips.org \
    --cc=thomas@osterried.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.