numam-dpdk/lib
Stefan Hajnoczi 2042cf7194 vhost: clear out unused SCM_RIGHTS file descriptors
The number of file descriptors received is not stored by vhost_user.c.
vhost_user_set_mem_table() assumes that memory.nregions matches the
number of file descriptors received, but nothing guarantees this:

  for (i = 0; i < memory.nregions; i++)
      close(pmsg->fds[i]);

Another questionable code snippet is:

  case VHOST_USER_SET_LOG_FD:
      close(msg.fds[0]);

If not enough file descriptors were received then fds[] contains
uninitialized data from the stack (see read_fd_message()).  This might
cause non-vhost file descriptors to be closed if the uninitialized data
happens to match.

Refactoring vhost_user.c to pass around and check the number of file
descriptors everywhere would make the code more complex.  It is simpler
for read_fd_message() to set unused elements in fds[] to -1.  This way
close(-1) is called and no harm is done.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
2018-03-30 14:08:42 +02:00
..
librte_acl build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_bbdev bbdev: fix exported dynamic log type 2018-02-06 18:51:44 +01:00
librte_bitratestats bitratestats: fix library version in meson build 2018-03-28 00:07:35 +02:00
librte_cfgfile build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_cmdline cmdline: use SPDX tags 2018-02-01 02:27:22 +01:00
librte_compat compat: relicense some files 2018-02-06 23:13:47 +01:00
librte_cryptodev cryptodev: fix library version in meson build 2018-03-28 00:07:35 +02:00
librte_distributor build: set compat lib as universal dependency 2018-01-30 21:59:00 +01:00
librte_eal move kernel modules directories 2018-03-21 23:04:21 +01:00
librte_efd build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_ether ethdev: increase log level of port allocation failure 2018-02-13 16:32:16 +01:00
librte_eventdev eventdev: fix library version in meson build 2018-03-28 00:07:35 +02:00
librte_flow_classify build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_gro build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_gso build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_hash build: set compat lib as universal dependency 2018-01-30 21:59:00 +01:00
librte_ip_frag build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_jobstats build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_kni kni: set initial value for MTU 2018-02-01 01:03:26 +01:00
librte_kvargs kvargs: fix syntax in comments 2018-03-28 00:43:22 +02:00
librte_latencystats build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_lpm lpm: fix allocation of an existing object 2018-02-01 00:35:06 +01:00
librte_mbuf mbuf: fix logic of user mempool ops API 2018-02-06 01:02:12 +01:00
librte_member build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_mempool mempool: fix library version in meson build 2018-03-28 00:07:35 +02:00
librte_meter meter: fix library version in meson build 2018-03-28 00:07:35 +02:00
librte_metrics build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_net net: use SPDX tags 2018-02-01 02:27:22 +01:00
librte_pci pci: remove duplicated symbol from map file 2018-03-22 17:34:48 +01:00
librte_pdump pdump: fix library version in meson build 2018-03-28 00:07:35 +02:00
librte_pipeline build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_port build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_power build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_rawdev rawdev: add self test 2018-01-31 15:35:56 +01:00
librte_reorder build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_ring lib: remove unused map symbols 2018-02-13 14:55:01 +01:00
librte_sched build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_security build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_table table: fix library version in meson build 2018-03-28 00:07:35 +02:00
librte_timer build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_vhost vhost: clear out unused SCM_RIGHTS file descriptors 2018-03-30 14:08:42 +02:00
Makefile rawdev: introduce raw device library 2018-01-31 15:35:01 +01:00
meson.build build: detect micro-arch on ARM 2018-01-30 21:59:00 +01:00