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-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu,  8 Oct 2015 14:32:02 +0300
From:	Sergei Zviagintsev <sergei@...v.net>
To:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Daniel Mack <daniel@...que.org>,
	David Herrmann <dh.herrmann@...glemail.com>,
	Djalal Harouni <tixxdz@...ndz.org>
Cc:	linux-kernel@...r.kernel.org, Sergei Zviagintsev <sergei@...v.net>
Subject: [PATCH 33/44] kdbus: Improve kdbus_staging_reserve()

Allow to reserve N elements in row. This eliminates duplicated code.

Signed-off-by: Sergei Zviagintsev <sergei@...v.net>
---
 ipc/kdbus/message.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/ipc/kdbus/message.c b/ipc/kdbus/message.c
index e337b1b1024a..f2176796390d 100644
--- a/ipc/kdbus/message.c
+++ b/ipc/kdbus/message.c
@@ -647,13 +647,14 @@ static int kdbus_staging_import(struct kdbus_staging *staging)
 	return 0;
 }
 
-static void kdbus_staging_reserve(struct kdbus_staging *staging)
+static void kdbus_staging_reserve(struct kdbus_staging *staging, size_t n)
 {
-	struct iovec *part;
+	while (n--) {
+		struct iovec *part = &staging->parts[staging->n_parts++];
 
-	part = &staging->parts[staging->n_parts++];
-	part->iov_base = (void __user *)zeros;
-	part->iov_len = 0;
+		part->iov_base = (void __user *)zeros;
+		part->iov_len = 0;
+	}
 }
 
 static struct kdbus_staging *kdbus_staging_new(struct kdbus_bus *bus,
@@ -701,16 +702,9 @@ static struct kdbus_staging *kdbus_staging_new(struct kdbus_bus *bus,
 	 *   * iovec for possible padding after the items
 	 *   * iovec for metadata items
 	 *   * iovec for possible padding after the items
-	 *
-	 * Make sure to update @reserved_parts if you add more parts here.
 	 */
 
-	kdbus_staging_reserve(staging); /* msg.size */
-	kdbus_staging_reserve(staging); /* msg (minus msg.size) plus items */
-	kdbus_staging_reserve(staging); /* msg padding */
-	kdbus_staging_reserve(staging); /* meta */
-	kdbus_staging_reserve(staging); /* meta padding */
-
+	kdbus_staging_reserve(staging, reserved_parts);
 	return staging;
 
 error:
@@ -814,7 +808,7 @@ struct kdbus_staging *kdbus_staging_new_user(struct kdbus_bus *bus,
 	 */
 
 	ret = kdbus_staging_import(staging); /* payload */
-	kdbus_staging_reserve(staging); /* payload padding */
+	kdbus_staging_reserve(staging, reserved_parts); /* payload padding */
 
 	if (ret < 0)
 		goto error;
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ