Skip to content

Commit 7062794

Browse files
schwabecron2
authored andcommitted
Remove --memstats feature
The ``--mememstat`` was largely undocumented and there is no known user of this feature. This feature provided very limited statistics (number of users, link bytes read/written) and we do not except any usage because of this. The only documentation was a mention in --help without any mention of the (binary) format of the mmap file or other usage instructions. This deals also with issues reported by zeropath regarding potentially insecure handling of the file permission of the memory mapped file. Reported-by: Joshua Rogers <[email protected]> Found-by: ZeroPath (https://zeropath.com/) Change-Id: I5f57e7bf52e3f6289462ef05e1f6e81ab0133d0d Signed-off-by: Arne Schwabe <[email protected]> Acked-by: Gert Doering <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1329 Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg34021.html Signed-off-by: Gert Doering <[email protected]>
1 parent f938d99 commit 7062794

File tree

12 files changed

+5
-257
lines changed

12 files changed

+5
-257
lines changed

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,6 @@ set(SOURCE_FILES
490490
src/openvpn/mroute.h
491491
src/openvpn/mss.c
492492
src/openvpn/mss.h
493-
src/openvpn/mstats.c
494-
src/openvpn/mstats.h
495493
src/openvpn/mtcp.c
496494
src/openvpn/mtcp.h
497495
src/openvpn/mtu.c

Changes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ Compression on send has been removed.
217217
``--allow-compression yes`` is now an alias for
218218
``--allow-compression asym``.
219219

220+
``--memstats`` feature removed
221+
The ``--mememstat`` was largely undocumented and there is no known
222+
user of this feature. This feature provided very limited statistics
223+
(number of users, link bytes read/written) and we do not except any
224+
usage because of this.
220225

221226
User-visible Changes
222227
--------------------

src/openvpn/Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ openvpn_SOURCES = \
9090
mbedtls_compat.h \
9191
mroute.c mroute.h \
9292
mss.c mss.h \
93-
mstats.c mstats.h \
9493
mtcp.c mtcp.h \
9594
mtu.c mtu.h \
9695
mudp.c mudp.h \

src/openvpn/error.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
#include "status.h"
3838
#include "integer.h"
3939
#include "ps.h"
40-
#include "mstats.h"
41-
4240

4341
#if SYSLOG_CAPABILITY
4442
#ifndef LOG_OPENVPN
@@ -723,10 +721,6 @@ openvpn_exit(const int status)
723721
}
724722
#endif
725723

726-
#ifdef ENABLE_MEMSTATS
727-
mstats_close();
728-
#endif
729-
730724
#ifdef ABORT_ON_ERROR
731725
if (status == OPENVPN_EXIT_STATUS_ERROR)
732726
{

src/openvpn/forward.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444

4545
#include "memdbg.h"
4646

47-
#include "mstats.h"
48-
4947
counter_type link_read_bytes_global; /* GLOBAL */
5048
counter_type link_write_bytes_global; /* GLOBAL */
5149

@@ -992,12 +990,6 @@ process_incoming_link_part1(struct context *c, struct link_socket_info *lsi, boo
992990
{
993991
c->c2.link_read_bytes += c->c2.buf.len;
994992
link_read_bytes_global += c->c2.buf.len;
995-
#ifdef ENABLE_MEMSTATS
996-
if (mmap_stats)
997-
{
998-
mmap_stats->link_read_bytes = link_read_bytes_global;
999-
}
1000-
#endif
1001993
c->c2.original_recv_size = c->c2.buf.len;
1002994
}
1003995
else
@@ -1821,12 +1813,6 @@ process_outgoing_link(struct context *c, struct link_socket *sock)
18211813
c->c2.max_send_size_local = max_int(size, c->c2.max_send_size_local);
18221814
c->c2.link_write_bytes += size;
18231815
link_write_bytes_global += size;
1824-
#ifdef ENABLE_MEMSTATS
1825-
if (mmap_stats)
1826-
{
1827-
mmap_stats->link_write_bytes = link_write_bytes_global;
1828-
}
1829-
#endif
18301816
}
18311817
}
18321818

src/openvpn/init.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include "ps.h"
4545
#include "lladdr.h"
4646
#include "ping.h"
47-
#include "mstats.h"
4847
#include "ssl_verify.h"
4948
#include "ssl_ncp.h"
5049
#include "tls_crypt.h"
@@ -908,22 +907,6 @@ init_static(void)
908907
return false;
909908
#endif
910909

911-
#ifdef MSTATS_TEST
912-
{
913-
int i;
914-
mstats_open("/dev/shm/mstats.dat");
915-
for (i = 0; i < 30; ++i)
916-
{
917-
mmap_stats->n_clients += 1;
918-
mmap_stats->link_write_bytes += 8;
919-
mmap_stats->link_read_bytes += 16;
920-
sleep(1);
921-
}
922-
mstats_close();
923-
return false;
924-
}
925-
#endif
926-
927910
return true;
928911
}
929912

@@ -1233,13 +1216,6 @@ do_uid_gid_chroot(struct context *c, bool no_delay)
12331216
}
12341217
}
12351218

1236-
#ifdef ENABLE_MEMSTATS
1237-
if (c->first_time && c->options.memstats_fn)
1238-
{
1239-
mstats_open(c->options.memstats_fn);
1240-
}
1241-
#endif
1242-
12431219
#ifdef ENABLE_SELINUX
12441220
/* Apply a SELinux context in order to restrict what OpenVPN can do
12451221
* to _only_ what it is supposed to do after initialization is complete

src/openvpn/mstats.c

Lines changed: 0 additions & 124 deletions
This file was deleted.

src/openvpn/mstats.h

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/openvpn/multi.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include "run_command.h"
3838
#include "otime.h"
3939
#include "gremlin.h"
40-
#include "mstats.h"
4140
#include "ssl_verify.h"
4241
#include "ssl_ncp.h"
4342
#include "vlan.h"
@@ -80,17 +79,6 @@ set_cc_config(struct multi_instance *mi, struct buffer_list *cc_config)
8079
}
8180
#endif
8281

83-
static inline void
84-
update_mstat_n_clients(const int n_clients)
85-
{
86-
#ifdef ENABLE_MEMSTATS
87-
if (mmap_stats)
88-
{
89-
mmap_stats->n_clients = n_clients;
90-
}
91-
#endif
92-
}
93-
9482
static bool
9583
learn_address_script(const struct multi_context *m, const struct multi_instance *mi, const char *op,
9684
const struct mroute_addr *addr)
@@ -589,7 +577,6 @@ multi_close_instance(struct multi_context *m, struct multi_instance *mi, bool sh
589577

590578
/* adjust current client connection count */
591579
m->n_clients += mi->n_clients_delta;
592-
update_mstat_n_clients(m->n_clients);
593580
mi->n_clients_delta = 0;
594581

595582
/* prevent dangling pointers */
@@ -2799,7 +2786,6 @@ multi_connection_established(struct multi_context *m, struct multi_instance *mi)
27992786

28002787
/* increment number of current authenticated clients */
28012788
++m->n_clients;
2802-
update_mstat_n_clients(m->n_clients);
28032789
--mi->n_clients_delta;
28042790

28052791
#ifdef ENABLE_MANAGEMENT

src/openvpn/options.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,6 @@ static const char usage_message[] =
323323
" via a VRF present on the system.\n"
324324
#endif
325325
"--txqueuelen n : Set the tun/tap TX queue length to n (Linux only).\n"
326-
#ifdef ENABLE_MEMSTATS
327-
"--memstats file : Write live usage stats to memory mapped binary file.\n"
328-
#endif
329326
"--mlock : Disable Paging -- ensures key material and tunnel\n"
330327
" data will never be written to disk.\n"
331328
"--up cmd : Run command cmd after successful tun device open.\n"
@@ -6333,13 +6330,6 @@ add_option(struct options *options, char *p[], bool is_inline, const char *file,
63336330
options->log = true;
63346331
redirect_stdout_stderr(p[1], true);
63356332
}
6336-
#ifdef ENABLE_MEMSTATS
6337-
else if (streq(p[0], "memstats") && p[1] && !p[2])
6338-
{
6339-
VERIFY_PERMISSION(OPT_P_GENERAL);
6340-
options->memstats_fn = p[1];
6341-
}
6342-
#endif
63436333
else if (streq(p[0], "mlock") && !p[1])
63446334
{
63456335
VERIFY_PERMISSION(OPT_P_GENERAL);

0 commit comments

Comments
 (0)