summaryrefslogtreecommitdiffstats
path: root/kdbus-skip-mandatory-items-on-negotiation.patch
diff options
context:
space:
mode:
authorJosh Boyer <jwboyer@fedoraproject.org>2015-07-08 10:30:06 -0400
committerJosh Boyer <jwboyer@fedoraproject.org>2015-07-08 10:30:06 -0400
commit8be443055ee741775545f3d86cbfd36410c6ef8d (patch)
tree90c6fda25ceb55bee60a1d8a30f436eb3b9e1277 /kdbus-skip-mandatory-items-on-negotiation.patch
parent84bb446543a6e771a1be4fc09b0712607bc6a376 (diff)
downloadkernel-8be443055ee741775545f3d86cbfd36410c6ef8d.tar.gz
kernel-8be443055ee741775545f3d86cbfd36410c6ef8d.tar.xz
kernel-8be443055ee741775545f3d86cbfd36410c6ef8d.zip
Linux v4.2-rc1-33-gd6ac4ffc61ac
Diffstat (limited to 'kdbus-skip-mandatory-items-on-negotiation.patch')
-rw-r--r--kdbus-skip-mandatory-items-on-negotiation.patch55
1 files changed, 55 insertions, 0 deletions
diff --git a/kdbus-skip-mandatory-items-on-negotiation.patch b/kdbus-skip-mandatory-items-on-negotiation.patch
new file mode 100644
index 000000000..a5f1cf83f
--- /dev/null
+++ b/kdbus-skip-mandatory-items-on-negotiation.patch
@@ -0,0 +1,55 @@
+From: David Herrmann <dh.herrmann@gmail.com>
+Date: Thu, 21 May 2015 20:03:29 +0200
+Subject: [PATCH] kdbus: skip mandatory items on negotiation
+
+The kdbus negotiation is used to figure out what items and flags an ioctl
+supports. It is highly impractical to pass in mandatory items when all we
+do is negotiation. Therefore, allow user-space to skip mandatory items if
+KDBUS_FLAG_NEGOTIATE is passed.
+
+Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
+Acked-by: Daniel Mack <daniel@zonque.org>
+---
+ ipc/kdbus/handle.c | 15 ++++++++++-----
+ 1 file changed, 10 insertions(+), 5 deletions(-)
+
+diff --git a/ipc/kdbus/handle.c b/ipc/kdbus/handle.c
+index f72dbe513b4a..3f5d8085a297 100644
+--- a/ipc/kdbus/handle.c
++++ b/ipc/kdbus/handle.c
+@@ -71,10 +71,6 @@ static int kdbus_args_verify(struct kdbus_args *args)
+ if (!KDBUS_ITEMS_END(item, args->items, args->items_size))
+ return -EINVAL;
+
+- for (i = 0; i < args->argc; ++i)
+- if (args->argv[i].mandatory && !args->argv[i].item)
+- return -EINVAL;
+-
+ return 0;
+ }
+
+@@ -149,7 +145,7 @@ static int kdbus_args_negotiate(struct kdbus_args *args)
+ int __kdbus_args_parse(struct kdbus_args *args, void __user *argp,
+ size_t type_size, size_t items_offset, void **out)
+ {
+- int ret;
++ int ret, i;
+
+ args->cmd = kdbus_memdup_user(argp, type_size, KDBUS_CMD_MAX_SIZE);
+ if (IS_ERR(args->cmd))
+@@ -173,6 +169,15 @@ int __kdbus_args_parse(struct kdbus_args *args, void __user *argp,
+ if (ret < 0)
+ goto error;
+
++ /* mandatory items must be given (but not on negotiation) */
++ if (!(args->cmd->flags & KDBUS_FLAG_NEGOTIATE)) {
++ for (i = 0; i < args->argc; ++i)
++ if (args->argv[i].mandatory && !args->argv[i].item) {
++ ret = -EINVAL;
++ goto error;
++ }
++ }
++
+ *out = args->cmd;
+ return !!(args->cmd->flags & KDBUS_FLAG_NEGOTIATE);
+