Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Jul 2019 16:28:50 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r350054 - head/lib/libnv
Message-ID:  <201907161628.x6GGSoAG034069@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Tue Jul 16 16:28:50 2019
New Revision: 350054
URL: https://svnweb.freebsd.org/changeset/base/350054

Log:
  Use a platform-independent constant for PKG_MAX_SIZE.
  
  This constant determines the number of rights libnv will attempt to
  transmit in a given control message.  In practice, the upper limit
  defined by the kernel is machine-dependent and is smaller on 64-bit
  kernels than on 32-bit kernels.  To ensure that a 32-bit libnv works
  as expected when run on a 64-bit kernel, use a limit that will work
  on both 32-bit and 64-bit kernels.
  
  PR:		238511
  Discussed with:	oshogbo
  MFC after:	3 days
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20942

Modified:
  head/lib/libnv/msgio.c

Modified: head/lib/libnv/msgio.c
==============================================================================
--- head/lib/libnv/msgio.c	Tue Jul 16 16:26:51 2019	(r350053)
+++ head/lib/libnv/msgio.c	Tue Jul 16 16:28:50 2019	(r350054)
@@ -63,7 +63,13 @@ __FBSDID("$FreeBSD$");
 /* Linux: arbitrary size, but must be lower than SCM_MAX_FD. */
 #define	PKG_MAX_SIZE	((64U - 1) * CMSG_SPACE(sizeof(int)))
 #else
-#define	PKG_MAX_SIZE	(MCLBYTES / CMSG_SPACE(sizeof(int)) - 1)
+/*
+ * To work around limitations in 32-bit emulation on 64-bit kernels, use a
+ * machine-independent limit on the number of FDs per message.  Each control
+ * message contains 1 FD and requires 12 bytes for the header, 4 pad bytes,
+ * 4 bytes for the descriptor, and another 4 pad bytes.
+ */
+#define	PKG_MAX_SIZE	(MCLBYTES / 24)
 #endif
 
 static int



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201907161628.x6GGSoAG034069>