lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190130072933.23281-1-vakul.garg@nxp.com>
Date:   Wed, 30 Jan 2019 07:31:44 +0000
From:   Vakul Garg <vakul.garg@....com>
To:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>
CC:     "borisp@...lanox.com" <borisp@...lanox.com>,
        "aviadye@...lanox.com" <aviadye@...lanox.com>,
        "davejwatson@...com" <davejwatson@...com>,
        "davem@...emloft.net" <davem@...emloft.net>,
        "doronrk@...com" <doronrk@...com>, Vakul Garg <vakul.garg@....com>
Subject: [PATCH net-next] strparser: Return if socket does not have required
 number of bytes

Function strp_data_ready() should peek the associated socket to check
whether it has the required number of bytes available before queueing
work or initiating socket read via strp_read_sock(). This saves cpu
cycles because strp_read_sock() is called only when required amount of
data is available.

Signed-off-by: Vakul Garg <vakul.garg@....com>
---
 net/strparser/strparser.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/net/strparser/strparser.c b/net/strparser/strparser.c
index da1a676860ca..38f8d8d8f4ad 100644
--- a/net/strparser/strparser.c
+++ b/net/strparser/strparser.c
@@ -384,6 +384,14 @@ void strp_data_ready(struct strparser *strp)
 	if (unlikely(strp->stopped) || strp->paused)
 		return;
 
+	/* If the socket does not contain the number bytes required by
+	 * stream parser context to proceed, return silently.
+	 */
+	if (strp->need_bytes) {
+		if (strp_peek_len(strp) < strp->need_bytes)
+			return;
+	}
+
 	/* This check is needed to synchronize with do_strp_work.
 	 * do_strp_work acquires a process lock (lock_sock) whereas
 	 * the lock held here is bh_lock_sock. The two locks can be
@@ -396,11 +404,6 @@ void strp_data_ready(struct strparser *strp)
 		return;
 	}
 
-	if (strp->need_bytes) {
-		if (strp_peek_len(strp) < strp->need_bytes)
-			return;
-	}
-
 	if (strp_read_sock(strp) == -ENOMEM)
 		queue_work(strp_wq, &strp->work);
 }
-- 
2.13.6

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ