kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: valdis.kletnieks@vt.edu
To: noloader@gmail.com
Cc: kernelnewbies <kernelnewbies@kernelnewbies.org>
Subject: Re: undefined reference to `ioctl_tty'
Date: Wed, 06 Mar 2019 03:36:07 -0500	[thread overview]
Message-ID: <8142.1551861367@turing-police> (raw)
In-Reply-To: <CAH8yC8k5nG4A0OVTwY9rhyQP=mJ1CS2rYBnUrUBm2BBAw4aOsw@mail.gmail.com>

On Wed, 06 Mar 2019 01:58:41 -0500, Jeffrey Walton said:

>        TIOCEXCL  void
>               Put the terminal into exclusive mode.  No further open(2)
>               operations on the terminal are permitted.  (They fail with
>               EBUSY, except for a process with the CAP_SYS_ADMIN
>               capability.)

Note that this is still slightly racy - if two processes both try to do an open
and an ioctl, this can happen:

Process 1	open()
		Process 2 open()
Process 1 ioctl(TIOEXCL)
		Process 2 ioctl()

But at this point, the second process has already succeeded in opening the
device, so "no further opens" doesn't save you.

Usually, this sort of race would be really hard to hit, especially if the
ioctl() happens right after the open() - except that many systems will use cron
or similar to launch stuff "once per hour" or similar.  And they end up
batching together two processes that each try to do this. Suddenly, it's a lot
easier to hit that hole when cron launches two processes at 12:54:17 PM.....

If there's one thing I've learned from almost 4 decades of sysadmin'ing on all
sorts of systems, saying "Oh that timing hole is so tiny it won't ever get hit
in production" guarantees that the Clock Gods will smite you for your hubris.

:)


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  parent reply	other threads:[~2019-03-06  8:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-06  6:58 undefined reference to `ioctl_tty' Jeffrey Walton
     [not found] ` <CAJ1xhMXLdhsj4R8MmbR1WkbO7wBV+gJdeJW+XH+7ONV3WkNHNw@mail.gmail.com>
2019-03-06  7:31   ` Fwd: " Alexander Kapshuk
2019-03-06  7:41     ` Jeffrey Walton
2019-03-06  8:36 ` valdis.kletnieks [this message]
2019-03-06  8:50   ` Jeffrey Walton
2019-03-07  8:59     ` valdis.kletnieks

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=8142.1551861367@turing-police \
    --to=valdis.kletnieks@vt.edu \
    --cc=kernelnewbies@kernelnewbies.org \
    --cc=noloader@gmail.com \
    /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 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).