Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754935AbbHFIV7 (ORCPT ); Thu, 6 Aug 2015 04:21:59 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:35021 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754689AbbHFIV4 (ORCPT ); Thu, 6 Aug 2015 04:21:56 -0400 From: David Herrmann To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Daniel Mack , Djalal Harouni , David Herrmann Subject: [PATCH 1/9] kdbus: return EBADSLT on replies without slot Date: Thu, 6 Aug 2015 10:21:20 +0200 Message-Id: <1438849288-18112-2-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1438849288-18112-1-git-send-email-dh.herrmann@gmail.com> References: <1438849288-18112-1-git-send-email-dh.herrmann@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2334 Lines: 63 If you send a reply without an active reply slot, we used to return EPERM. However, this makes it impossible to distinguish this case from a real permission-denied error (eg., LSM). Hence, make sure we return a unique error-code if the reply-slot is missing. With this patch, you get EBADSLT ("Invalid slot") if you call KDBUS_CMD_SEND with a reply-cookie that has no valid slot. Reviewed-by: Daniel Mack Signed-off-by: David Herrmann --- ipc/kdbus/connection.c | 2 +- tools/testing/selftests/kdbus/test-message.c | 2 +- tools/testing/selftests/kdbus/test-sync.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c index d94b417..2787bd7 100644 --- a/ipc/kdbus/connection.c +++ b/ipc/kdbus/connection.c @@ -1123,7 +1123,7 @@ static int kdbus_conn_reply(struct kdbus_conn *src, mutex_unlock(&dst->lock); if (!reply) { - ret = -EPERM; + ret = -EBADSLT; goto exit; } diff --git a/tools/testing/selftests/kdbus/test-message.c b/tools/testing/selftests/kdbus/test-message.c index ddc1e0a..563dc85 100644 --- a/tools/testing/selftests/kdbus/test-message.c +++ b/tools/testing/selftests/kdbus/test-message.c @@ -75,7 +75,7 @@ int kdbus_test_message_basic(struct kdbus_test_env *env) /* Faked replies with a valid reply cookie are rejected */ ret = kdbus_msg_send_reply(conn, time(NULL) ^ cookie, sender->id); - ASSERT_RETURN(ret == -EPERM); + ASSERT_RETURN(ret == -EBADSLT); ret = kdbus_free(conn, offset); ASSERT_RETURN(ret == 0); diff --git a/tools/testing/selftests/kdbus/test-sync.c b/tools/testing/selftests/kdbus/test-sync.c index e2be910..0655a54 100644 --- a/tools/testing/selftests/kdbus/test-sync.c +++ b/tools/testing/selftests/kdbus/test-sync.c @@ -235,7 +235,7 @@ static void *run_thread_reply(void *data) /* using an unknown cookie must fail */ ret = kdbus_msg_send_reply(conn_a, ~cookie, conn_b->id); - if (ret != -EPERM) { + if (ret != -EBADSLT) { status = TEST_ERR; goto exit_thread; } -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/