Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200520064726.31838-3-o-takashi@sakamocchi.jp>
Date: Wed, 20 May 2020 15:47:26 +0900
From: Takashi Sakamoto <o-takashi@...amocchi.jp>
To: oscar.carter@....com,
	keescook@...omium.org,
	mchehab@...nel.org,
	clemens@...isch.de,
	tiwai@...e.de,
	perex@...ex.cz
Cc: kernel-hardening@...ts.openwall.com,
	linux1394-devel@...ts.sourceforge.net,
	linux-kernel@...r.kernel.org,
	linux-media@...r.kernel.org,
	levonshe@...il.com,
	alsa-devel@...a-project.org,
	stefanr@...6.in-berlin.de
Subject: [PATCH 2/2] firewire-core: obsolete cast of function callback

This commit obsoletes cast of function callback to assist attempt of
Control Flow Integrity builds.

Reported-by: Oscar Carter <oscar.carter@....com>
Reference: https://lore.kernel.org/lkml/20200519173425.4724-1-oscar.carter@gmx.com/
Signed-off-by: Takashi Sakamoto <o-takashi@...amocchi.jp>
---
 drivers/firewire/core-cdev.c | 44 +++++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 21 deletions(-)

diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
index 6e291d8f3a27..f1e83396dd22 100644
--- a/drivers/firewire/core-cdev.c
+++ b/drivers/firewire/core-cdev.c
@@ -957,7 +957,6 @@ static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg)
 {
 	struct fw_cdev_create_iso_context *a = &arg->create_iso_context;
 	struct fw_iso_context *context;
-	fw_iso_callback_t cb;
 	int ret;
 
 	BUILD_BUG_ON(FW_CDEV_ISO_CONTEXT_TRANSMIT != FW_ISO_CONTEXT_TRANSMIT ||
@@ -965,32 +964,35 @@ static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg)
 		     FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL !=
 					FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL);
 
-	switch (a->type) {
-	case FW_ISO_CONTEXT_TRANSMIT:
-		if (a->speed > SCODE_3200 || a->channel > 63)
-			return -EINVAL;
-
-		cb = iso_callback;
-		break;
+	if (a->type != FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL) {
+		fw_iso_callback_t cb;
 
-	case FW_ISO_CONTEXT_RECEIVE:
-		if (a->header_size < 4 || (a->header_size & 3) ||
-		    a->channel > 63)
-			return -EINVAL;
+		switch (a->type) {
+		case FW_ISO_CONTEXT_TRANSMIT:
+			if (a->speed > SCODE_3200 || a->channel > 63)
+				return -EINVAL;
 
-		cb = iso_callback;
-		break;
+			cb = iso_callback;
+			break;
 
-	case FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL:
-		cb = (fw_iso_callback_t)iso_mc_callback;
-		break;
+		case FW_ISO_CONTEXT_RECEIVE:
+			if (a->header_size < 4 || (a->header_size & 3) ||
+			    a->channel > 63)
+				return -EINVAL;
 
-	default:
-		return -EINVAL;
-	}
+			cb = iso_callback;
+			break;
+		default:
+			return -EINVAL;
+		}
 
-	context = fw_iso_context_create(client->device->card, a->type,
+		context = fw_iso_context_create(client->device->card, a->type,
 			a->channel, a->speed, a->header_size, cb, client);
+	} else {
+		context = fw_iso_mc_context_create(client->device->card,
+				a->type, a->channel, a->speed, a->header_size,
+				iso_mc_callback, client);
+	}
 	if (IS_ERR(context))
 		return PTR_ERR(context);
 	if (client->version < FW_CDEV_VERSION_AUTO_FLUSH_ISO_OVERFLOW)
-- 
2.25.1

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.