public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Herrmann <dh.herrmann@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	daniel@zonque.org, tixxdz@opendz.org,
	Sergei Zviagintsev <sergei@s15v.net>,
	David Herrmann <dh.herrmann@gmail.com>
Subject: [PATCH v2 2/6] kdbus: drop redundant KDBUS_MSG_MAX_ITEMS
Date: Sat,  4 Jul 2015 13:22:47 +0200	[thread overview]
Message-ID: <1436008967-18753-1-git-send-email-dh.herrmann@gmail.com> (raw)
In-Reply-To: <1435825714-3567-3-git-send-email-dh.herrmann@gmail.com>

We already limit the size of the message object, there's no reason to add
an arbitrary additional limit on the number of items. We don't do this for
other item-arrays, so lets stop restricting the messages in this way.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
v2:
 - drop redundant "n = 0" assignment
 - rename 'n' to 'n_res'

 ipc/kdbus/limits.h  |  3 ---
 ipc/kdbus/message.c | 12 ++++--------
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/ipc/kdbus/limits.h b/ipc/kdbus/limits.h
index 6450f58..c54925a 100644
--- a/ipc/kdbus/limits.h
+++ b/ipc/kdbus/limits.h
@@ -19,9 +19,6 @@
 /* maximum size of message header and items */
 #define KDBUS_MSG_MAX_SIZE		SZ_8K
 
-/* maximum number of message items */
-#define KDBUS_MSG_MAX_ITEMS		128
-
 /* maximum number of memfd items per message */
 #define KDBUS_MSG_MAX_MEMFD_ITEMS	16
 
diff --git a/ipc/kdbus/message.c b/ipc/kdbus/message.c
index 066e816..e9da672 100644
--- a/ipc/kdbus/message.c
+++ b/ipc/kdbus/message.c
@@ -214,7 +214,7 @@ static int kdbus_msg_scan_items(struct kdbus_kmsg *kmsg,
 	struct kdbus_msg_resources *res = kmsg->res;
 	const struct kdbus_msg *msg = &kmsg->msg;
 	const struct kdbus_item *item;
-	size_t n, n_vecs, n_memfds;
+	size_t n_res, n_vecs, n_memfds;
 	bool has_bloom = false;
 	bool has_name = false;
 	bool has_fds = false;
@@ -243,9 +243,9 @@ static int kdbus_msg_scan_items(struct kdbus_kmsg *kmsg,
 		}
 	}
 
-	n = n_vecs + n_memfds;
-	if (n > 0) {
-		res->data = kcalloc(n, sizeof(*res->data), GFP_KERNEL);
+	n_res = n_vecs + n_memfds;
+	if (n_res > 0) {
+		res->data = kcalloc(n_res, sizeof(*res->data), GFP_KERNEL);
 		if (!res->data)
 			return -ENOMEM;
 	}
@@ -257,15 +257,11 @@ static int kdbus_msg_scan_items(struct kdbus_kmsg *kmsg,
 	}
 
 	/* import data payloads */
-	n = 0;
 	vec_size = 0;
 	KDBUS_ITEMS_FOREACH(item, msg->items, KDBUS_ITEMS_SIZE(msg, items)) {
 		size_t payload_size = KDBUS_ITEM_PAYLOAD_SIZE(item);
 		struct iovec *iov = kmsg->iov + kmsg->iov_count;
 
-		if (++n > KDBUS_MSG_MAX_ITEMS)
-			return -E2BIG;
-
 		switch (item->type) {
 		case KDBUS_ITEM_PAYLOAD_VEC: {
 			struct kdbus_msg_data *d = res->data + res->data_count;
-- 
2.4.5


  parent reply	other threads:[~2015-07-05  8:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-02  8:28 [PATCH 0/6] Miscellaneous kdbus fixes and code removal David Herrmann
2015-07-02  8:28 ` [PATCH 1/6] kdbus/selftests: fix CAP translation tests David Herrmann
2015-07-02  8:28 ` [PATCH 2/6] kdbus: drop redundant KDBUS_MSG_MAX_ITEMS David Herrmann
2015-07-03 21:14   ` Sergei Zviagintsev
2015-07-04 11:22   ` David Herrmann [this message]
2015-07-02  8:28 ` [PATCH 3/6] kdbus: drop unused 'bloom_generation' field David Herrmann
2015-07-02  8:28 ` [PATCH 4/6] kdbus: drop support for required attach-flags on buses David Herrmann
2015-07-02  8:28 ` [PATCH 5/6] kdbus: pin namespaces on HELLO David Herrmann
2015-07-03 21:44   ` Sergei Zviagintsev
2015-07-04 11:26     ` David Herrmann
2015-07-02  8:28 ` [PATCH 6/6] kdbus: fix NULL-deref in activator cleanup David Herrmann
2015-07-06 18:49 ` [PATCH 0/6] Miscellaneous kdbus fixes and code removal David Herrmann

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=1436008967-18753-1-git-send-email-dh.herrmann@gmail.com \
    --to=dh.herrmann@gmail.com \
    --cc=daniel@zonque.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sergei@s15v.net \
    --cc=tixxdz@opendz.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox