All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Sakoman <steve@sakoman.com>
To: openembedded-core@lists.openembedded.org
Subject: [OE-core][kirkstone 02/29] libtirpc: CVE-2021-46828 DoS vulnerability with lots of connections
Date: Fri, 29 Jul 2022 04:46:18 -1000	[thread overview]
Message-ID: <7eeaf4e400bf57fc9d0a376085d1788bc5c146b3.1659105705.git.steve@sakoman.com> (raw)
In-Reply-To: <cover.1659105705.git.steve@sakoman.com>

From: Hitendra Prajapati <hprajapati@mvista.com>

Source: http://git.linux-nfs.org/?p=steved/libtirpc.git;
MR: 120225
Type: Security Fix
Disposition: Backport from http://git.linux-nfs.org/?p=steved/libtirpc.git;a=commit;h=86529758570cef4c73fb9b9c4104fdc510f701ed
ChangeID: 29c32ee171a6a47e06c788e5c608fac9bb3a64b2
Description:
        CVE-2021-46828 libtirpc: DoS vulnerability with lots of connections.

Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
---
 .../libtirpc/libtirpc/CVE-2021-46828.patch    | 155 ++++++++++++++++++
 .../libtirpc/libtirpc_1.3.2.bb                |   4 +-
 2 files changed, 158 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-extended/libtirpc/libtirpc/CVE-2021-46828.patch

diff --git a/meta/recipes-extended/libtirpc/libtirpc/CVE-2021-46828.patch b/meta/recipes-extended/libtirpc/libtirpc/CVE-2021-46828.patch
new file mode 100644
index 0000000000..3d5e5b8db9
--- /dev/null
+++ b/meta/recipes-extended/libtirpc/libtirpc/CVE-2021-46828.patch
@@ -0,0 +1,155 @@
+From 3ee23a0a5a8c2261e788acbee67722fcbecbea28 Mon Sep 17 00:00:00 2001
+From: Hitendra Prajapati <hprajapati@mvista.com>
+Date: Wed, 27 Jul 2022 17:34:21 +0530
+Subject: [PATCH] CVE-2021-46828
+
+Upstream-Status: Backport [http://git.linux-nfs.org/?p=steved/libtirpc.git;a=commit;h=86529758570cef4c73fb9b9c4104fdc510f701ed}
+CVE: CVE-2021-46828
+Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
+---
+ src/svc.c    | 17 +++++++++++++-
+ src/svc_vc.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++-
+ 2 files changed, 77 insertions(+), 2 deletions(-)
+
+diff --git a/src/svc.c b/src/svc.c
+index 6db164b..3a8709f 100644
+--- a/src/svc.c
++++ b/src/svc.c
+@@ -57,7 +57,7 @@
+ 
+ #define max(a, b) (a > b ? a : b)
+ 
+-static SVCXPRT **__svc_xports;
++SVCXPRT **__svc_xports;
+ int __svc_maxrec;
+ 
+ /*
+@@ -194,6 +194,21 @@ __xprt_do_unregister (xprt, dolock)
+     rwlock_unlock (&svc_fd_lock);
+ }
+ 
++int
++svc_open_fds()
++{
++	int ix;
++	int nfds = 0;
++
++	rwlock_rdlock (&svc_fd_lock);
++	for (ix = 0; ix < svc_max_pollfd; ++ix) {
++		if (svc_pollfd[ix].fd != -1)
++			nfds++;
++	}
++	rwlock_unlock (&svc_fd_lock);
++	return (nfds);
++}
++
+ /*
+  * Add a service program to the callout list.
+  * The dispatch routine will be called when a rpc request for this
+diff --git a/src/svc_vc.c b/src/svc_vc.c
+index f1d9f00..3dc8a75 100644
+--- a/src/svc_vc.c
++++ b/src/svc_vc.c
+@@ -64,6 +64,8 @@
+ 
+ 
+ extern rwlock_t svc_fd_lock;
++extern SVCXPRT **__svc_xports;
++extern int svc_open_fds();
+ 
+ static SVCXPRT *makefd_xprt(int, u_int, u_int);
+ static bool_t rendezvous_request(SVCXPRT *, struct rpc_msg *);
+@@ -82,6 +84,7 @@ static void svc_vc_ops(SVCXPRT *);
+ static bool_t svc_vc_control(SVCXPRT *xprt, const u_int rq, void *in);
+ static bool_t svc_vc_rendezvous_control (SVCXPRT *xprt, const u_int rq,
+ 				   	     void *in);
++static int __svc_destroy_idle(int timeout);
+ 
+ struct cf_rendezvous { /* kept in xprt->xp_p1 for rendezvouser */
+ 	u_int sendsize;
+@@ -313,13 +316,14 @@ done:
+ 	return (xprt);
+ }
+ 
++
+ /*ARGSUSED*/
+ static bool_t
+ rendezvous_request(xprt, msg)
+ 	SVCXPRT *xprt;
+ 	struct rpc_msg *msg;
+ {
+-	int sock, flags;
++	int sock, flags, nfds, cnt;
+ 	struct cf_rendezvous *r;
+ 	struct cf_conn *cd;
+ 	struct sockaddr_storage addr;
+@@ -379,6 +383,16 @@ again:
+ 
+ 	gettimeofday(&cd->last_recv_time, NULL);
+ 
++	nfds = svc_open_fds();
++	if (nfds >= (_rpc_dtablesize() / 5) * 4) {
++		/* destroy idle connections */
++		cnt = __svc_destroy_idle(15);
++		if (cnt == 0) {
++			/* destroy least active */
++			__svc_destroy_idle(0);
++		}
++	}
++
+ 	return (FALSE); /* there is never an rpc msg to be processed */
+ }
+ 
+@@ -820,3 +834,49 @@ __svc_clean_idle(fd_set *fds, int timeout, bool_t cleanblock)
+ {
+ 	return FALSE;
+ }
++
++static int
++__svc_destroy_idle(int timeout)
++{
++	int i, ncleaned = 0;
++	SVCXPRT *xprt, *least_active;
++	struct timeval tv, tdiff, tmax;
++	struct cf_conn *cd;
++
++	gettimeofday(&tv, NULL);
++	tmax.tv_sec = tmax.tv_usec = 0;
++	least_active = NULL;
++	rwlock_wrlock(&svc_fd_lock);
++
++	for (i = 0; i <= svc_max_pollfd; i++) {
++		if (svc_pollfd[i].fd == -1)
++			continue;
++		xprt = __svc_xports[i];
++		if (xprt == NULL || xprt->xp_ops == NULL ||
++			xprt->xp_ops->xp_recv != svc_vc_recv)
++			continue;
++		cd = (struct cf_conn *)xprt->xp_p1;
++		if (!cd->nonblock)
++			continue;
++		if (timeout == 0) {
++			timersub(&tv, &cd->last_recv_time, &tdiff);
++			if (timercmp(&tdiff, &tmax, >)) {
++				tmax = tdiff;
++				least_active = xprt;
++			}
++			continue;
++		}
++		if (tv.tv_sec - cd->last_recv_time.tv_sec > timeout) {
++			__xprt_unregister_unlocked(xprt);
++			__svc_vc_dodestroy(xprt);
++			ncleaned++;
++		}
++	}
++	if (timeout == 0 && least_active != NULL) {
++		__xprt_unregister_unlocked(least_active);
++		__svc_vc_dodestroy(least_active);
++		ncleaned++;
++	}
++	rwlock_unlock(&svc_fd_lock);
++	return (ncleaned);
++}
+-- 
+2.25.1
+
diff --git a/meta/recipes-extended/libtirpc/libtirpc_1.3.2.bb b/meta/recipes-extended/libtirpc/libtirpc_1.3.2.bb
index 45b3d2befc..66bc4ecdd1 100644
--- a/meta/recipes-extended/libtirpc/libtirpc_1.3.2.bb
+++ b/meta/recipes-extended/libtirpc/libtirpc_1.3.2.bb
@@ -9,7 +9,9 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=f835cce8852481e4b2bbbdd23b5e47f3 \
 
 PROVIDES = "virtual/librpc"
 
-SRC_URI = "${SOURCEFORGE_MIRROR}/${BPN}/${BP}.tar.bz2"
+SRC_URI = "${SOURCEFORGE_MIRROR}/${BPN}/${BP}.tar.bz2 \
+	   file://CVE-2021-46828.patch \
+	  "
 UPSTREAM_CHECK_URI = "https://sourceforge.net/projects/libtirpc/files/libtirpc/"
 UPSTREAM_CHECK_REGEX = "(?P<pver>\d+(\.\d+)+)/"
 SRC_URI[sha256sum] = "e24eb88b8ce7db3b7ca6eb80115dd1284abc5ec32a8deccfed2224fc2532b9fd"
-- 
2.25.1



  parent reply	other threads:[~2022-07-29 14:47 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-29 14:46 [OE-core][kirkstone 00/29] Patch review Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 01/29] qemu: CVE-2022-35414 can perform an uninitialized read on the translate_fail path, leading to an io_readx or io_writex crash Steve Sakoman
2022-08-02 14:41   ` Richard Purdie
2022-08-02 17:13     ` Steve Sakoman
2022-07-29 14:46 ` Steve Sakoman [this message]
2022-07-29 14:46 ` [OE-core][kirkstone 03/29] mkfontscale: upgrade 1.2.1 -> 1.2.2 Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 04/29] xdpyinfo: upgrade 1.3.2 -> 1.3.3 Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 05/29] xorg-app: Tweak handling of compression changes in SRC_URI Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 06/29] xev: update 1.2.4 -> 1.2.5 Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 07/29] xmodmap: update 1.0.10 -> 1.0.11 Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 08/29] xf86-input-synaptics: update 1.9.1 -> 1.9.2 Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 09/29] encodings: update 1.0.5 -> 1.0.6 Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 10/29] font-util: update 1.3.2 -> 1.3.3 Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 11/29] xserver-xorg: update 21.1.3 -> 21.1.4 Steve Sakoman
2022-08-02  5:56   ` Marta Rybczynska
2022-08-02  5:57     ` Marta Rybczynska
2022-08-02 14:09       ` Steve Sakoman
2022-08-02 14:37     ` Steve Sakoman
     [not found]     ` <17078DEC65A79A88.27835@lists.openembedded.org>
2022-08-02 14:57       ` Steve Sakoman
2022-08-02 16:19         ` Marta Rybczynska
2022-08-02 17:06           ` Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 12/29] linux-firmware: update 20220610 -> 20220708 Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 13/29] libuv: upgrade 1.44.1 -> 1.44.2 Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 14/29] log4cplus: upgrade 2.0.7 -> 2.0.8 Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 15/29] vala: upgrade 0.56.0 -> 0.56.1 Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 16/29] vala: upgrade 0.56.1 -> 0.56.2 Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 17/29] webkitgtk: upgrade 2.36.3 -> 2.36.4 Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 18/29] xwayland: upgrade 22.1.1 -> 22.1.2 Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 19/29] xwayland: upgrade 22.1.2 -> 22.1.3 Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 20/29] epiphany: upgrade 42.2 -> 42.3 Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 21/29] oeqa/runtime: add test that the kernel has CONFIG_PREEMPT_RT enabled Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 22/29] wic/plugins/rootfs: Fix NameError for 'orig_path' Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 23/29] systemd: Added base_bindir into pkg_postinst:udev-hwdb Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 24/29] udev-extraconf:mount.sh: fix a umount issue Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 25/29] perf: fix reproduciblity in older releases of Linux Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 26/29] base/reproducible: Change Source Date Epoch generation methods Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 27/29] efivar: fix import functionality Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 28/29] bind: Remove legacy python3 PACKAGECONFIG code Steve Sakoman
2022-07-29 14:46 ` [OE-core][kirkstone 29/29] initscripts: run umountnfs as a KILL script Steve Sakoman

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=7eeaf4e400bf57fc9d0a376085d1788bc5c146b3.1659105705.git.steve@sakoman.com \
    --to=steve@sakoman.com \
    --cc=openembedded-core@lists.openembedded.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.