/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to intro.xml

  • Committer: teddy at recompile
  • Date: 2020-04-05 21:30:59 UTC
  • Revision ID: teddy@recompile.se-20200405213059-fb2a61ckqynrmatk
Fix file descriptor leak in mandos-client

When the local network has Mandos servers announcing themselves using
real, globally reachable, IPv6 addresses (i.e. not link-local
addresses), but there is no router on the local network providing IPv6
RA (Router Advertisement) packets, the client cannot reach the server
by normal means, since the client only has a link-local IPv6 address,
and has no usable route to reach the server's global IPv6 address.
(This is not a common situation, and usually only happens when the
router itself reboots and runs a Mandos client, since it cannot then
give RA packets to itself.)  The client code has a solution for
this, which consists of adding a temporary local route to reach the
address of the server during communication, and removing this
temporary route afterwards.

This solution with a temporary route works, but has a file descriptor
leak; it leaks one file descriptor for each addition and for each
removal of a route.  If one server requiring an added route is present
on the network, but no servers gives a password, making the client
retry after the default ten seconds, and we furthermore assume a
default 1024 open files limit, the client runs out of file descriptors
after about 90 minutes, after which time the client process will be
useless and fail to retrieve any passwords, necessitating manual
password entry via the keyboard.

Fix this by eliminating the file descriptor leak in the client.

* plugins.d/mandos-client.c (add_delete_local_route): Do
  close(devnull) also in parent process, also if fork() fails, and on
  any failure in child process.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?xml version="1.0" encoding="UTF-8"?>
2
2
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3
3
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4
 
<!ENTITY TIMESTAMP "2017-02-23">
 
4
<!ENTITY TIMESTAMP "2019-08-04">
5
5
<!ENTITY % common SYSTEM "common.ent">
6
6
%common;
7
7
]>
37
37
      <year>2015</year>
38
38
      <year>2016</year>
39
39
      <year>2017</year>
 
40
      <year>2018</year>
 
41
      <year>2019</year>
40
42
      <holder>Teddy Hogeborn</holder>
41
43
      <holder>Björn Påhlsson</holder>
42
44
    </copyright>
66
68
      The computers run a small client program in the initial RAM disk
67
69
      environment which will communicate with a server over a network.
68
70
      All network communication is encrypted using TLS.  The clients
69
 
      are identified by the server using an OpenPGP key; each client
 
71
      are identified by the server using a TLS public key; each client
70
72
      has one unique to it.  The server sends the clients an encrypted
71
73
      password.  The encrypted password is decrypted by the clients
72
 
      using the same OpenPGP key, and the password is then used to
 
74
      using a separate OpenPGP key, and the password is then used to
73
75
      unlock the root file system, whereupon the computers can
74
76
      continue booting normally.
75
77
    </para>
129
131
    </para>
130
132
    <para>
131
133
      So, at boot time, the Mandos client will ask for its encrypted
132
 
      data over the network, decrypt it to get the password, use it to
133
 
      decrypt the root file, and continue booting.
 
134
      data over the network, decrypt the data to get the password, use
 
135
      the password to decrypt the root file system, and the client can
 
136
      then continue booting.
134
137
    </para>
135
138
    <para>
136
139
      Now, of course the initial RAM disk image is not on the
142
145
      long, and will no longer give out the encrypted key.  The timing
143
146
      here is the only real weak point, and the method, frequency and
144
147
      timeout of the server’s checking can be adjusted to any desired
145
 
      level of paranoia
 
148
      level of paranoia.
146
149
    </para>
147
150
    <para>
148
151
      (The encrypted keys on the Mandos server is on its normal file
199
202
      <para>
200
203
        No.  The server only gives out the passwords to clients which
201
204
        have <emphasis>in the TLS handshake</emphasis> proven that
202
 
        they do indeed hold the OpenPGP private key corresponding to
203
 
        that client.
 
205
        they do indeed hold the private key corresponding to that
 
206
        client.
204
207
      </para>
205
208
    </refsect2>
206
209
    
381
384
      plugin requirements.
382
385
    </para>
383
386
  </refsect1>
384
 
  
 
387
 
 
388
  <refsect1 id="systemd">
 
389
    <title>SYSTEMD</title>
 
390
    <para>
 
391
      More advanced startup systems like <citerefentry><refentrytitle
 
392
      >systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
 
393
      already have their own plugin-like mechanisms for allowing
 
394
      multiple agents to independently retrieve a password and deliver
 
395
      it to the subsystem requesting a password to unlock the root
 
396
      file system.  On these systems, it would make no sense to run
 
397
      <citerefentry><refentrytitle>plugin-runner</refentrytitle
 
398
      ><manvolnum>8mandos</manvolnum></citerefentry>, the plugins of
 
399
      which would largely duplicate the work of (and conflict with)
 
400
      the existing systems prompting for passwords.
 
401
    </para>
 
402
    <para>
 
403
      As for <citerefentry><refentrytitle>systemd</refentrytitle
 
404
      ><manvolnum>1</manvolnum></citerefentry> in particular, it has
 
405
      its own <ulink
 
406
      url="https://www.freedesktop.org/wiki/Software/systemd/PasswordAgents/"
 
407
      >Password Agents</ulink> system.  Mandos uses this via its
 
408
      <citerefentry><refentrytitle>password-agent</refentrytitle
 
409
      ><manvolnum>8mandos</manvolnum></citerefentry> program, which
 
410
      is run instead of <citerefentry><refentrytitle
 
411
      >plugin-runner</refentrytitle><manvolnum>8mandos</manvolnum
 
412
      ></citerefentry> when <citerefentry><refentrytitle
 
413
      >systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
 
414
      is used during system startup.
 
415
    </para>
 
416
  </refsect1>
385
417
  <refsect1 id="bugs">
386
418
    <title>BUGS</title>
387
419
    <xi:include href="bugs.xml"/>
402
434
      <manvolnum>8</manvolnum></citerefentry>,
403
435
      <citerefentry><refentrytitle>plugin-runner</refentrytitle>
404
436
      <manvolnum>8mandos</manvolnum></citerefentry>,
 
437
      <citerefentry><refentrytitle>password-agent</refentrytitle>
 
438
      <manvolnum>8mandos</manvolnum></citerefentry>,
405
439
      <citerefentry><refentrytitle>mandos-client</refentrytitle>
406
440
      <manvolnum>8mandos</manvolnum></citerefentry>,
407
441
      <citerefentry><refentrytitle>password-prompt</refentrytitle>