summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksandermj@chromium.org>2023-09-28 11:40:07 +0000
committerAleksander Morgado <aleksandermj@chromium.org>2023-09-29 08:53:16 +0000
commit8b264261a759217a45824587f905761963428c27 (patch)
tree70cc2e6ad0fa18270f2c2f30b5705e1cee5a9ac2
parente1a4622d81dca3b5f5d6f9c2ddd9b8ace726ec4d (diff)
libqmi-glib,endpoint-[mbim|qmux]: disallow private CTL operations
-rw-r--r--src/libqmi-glib/qmi-endpoint-mbim.c9
-rw-r--r--src/libqmi-glib/qmi-endpoint-qmux.c9
-rw-r--r--src/libqmi-glib/qmi-endpoint-qrtr.c5
-rw-r--r--src/libqmi-glib/qmi-endpoint.h6
4 files changed, 24 insertions, 5 deletions
diff --git a/src/libqmi-glib/qmi-endpoint-mbim.c b/src/libqmi-glib/qmi-endpoint-mbim.c
index 62ede9e..1f4e21c 100644
--- a/src/libqmi-glib/qmi-endpoint-mbim.c
+++ b/src/libqmi-glib/qmi-endpoint-mbim.c
@@ -334,6 +334,15 @@ endpoint_send (QmiEndpoint *self,
return FALSE;
}
+ /* Disallow private CTL operations */
+ if ((qmi_message_get_service (message) == QMI_SERVICE_CTL) &&
+ (qmi_message_get_message_id (message) == QMI_MESSAGE_CTL_ALLOCATE_CID_QRTR ||
+ qmi_message_get_message_id (message) == QMI_MESSAGE_CTL_RELEASE_CID_QRTR)) {
+ g_set_error (error, QMI_CORE_ERROR, QMI_CORE_ERROR_FAILED,
+ "MBIM endpoint expects only 8bit QMI services");
+ return FALSE;
+ }
+
/* Get raw message */
raw_message = qmi_message_get_raw (message, &raw_message_len, &inner_error);
if (!raw_message) {
diff --git a/src/libqmi-glib/qmi-endpoint-qmux.c b/src/libqmi-glib/qmi-endpoint-qmux.c
index aa7dcfe..e516e9d 100644
--- a/src/libqmi-glib/qmi-endpoint-qmux.c
+++ b/src/libqmi-glib/qmi-endpoint-qmux.c
@@ -473,6 +473,15 @@ endpoint_send (QmiEndpoint *self,
return FALSE;
}
+ /* Disallow private CTL operations */
+ if ((qmi_message_get_service (message) == QMI_SERVICE_CTL) &&
+ (qmi_message_get_message_id (message) == QMI_MESSAGE_CTL_ALLOCATE_CID_QRTR ||
+ qmi_message_get_message_id (message) == QMI_MESSAGE_CTL_RELEASE_CID_QRTR)) {
+ g_set_error (error, QMI_CORE_ERROR, QMI_CORE_ERROR_FAILED,
+ "QMUX endpoint expects only 8bit QMI services");
+ return FALSE;
+ }
+
/* Get raw message */
raw_message = qmi_message_get_raw (message, &raw_message_len, &inner_error);
if (!raw_message) {
diff --git a/src/libqmi-glib/qmi-endpoint-qrtr.c b/src/libqmi-glib/qmi-endpoint-qrtr.c
index c334a63..c78cb70 100644
--- a/src/libqmi-glib/qmi-endpoint-qrtr.c
+++ b/src/libqmi-glib/qmi-endpoint-qrtr.c
@@ -41,11 +41,6 @@
#define QMI_MESSAGE_OUTPUT_TLV_RESULT 0x02
-/* Constants for allocating/releasing clients */
-#define QMI_MESSAGE_CTL_ALLOCATE_CID 0x0022
-#define QMI_MESSAGE_CTL_RELEASE_CID 0x0023
-#define QMI_MESSAGE_CTL_ALLOCATE_CID_QRTR 0xFF22
-#define QMI_MESSAGE_CTL_RELEASE_CID_QRTR 0xFF23
#define QMI_MESSAGE_TLV_ALLOCATION_INFO 0x01
#define QMI_MESSAGE_INPUT_TLV_SERVICE 0x01
diff --git a/src/libqmi-glib/qmi-endpoint.h b/src/libqmi-glib/qmi-endpoint.h
index 545d174..c603867 100644
--- a/src/libqmi-glib/qmi-endpoint.h
+++ b/src/libqmi-glib/qmi-endpoint.h
@@ -31,6 +31,12 @@
#include "qmi-file.h"
#include "qmi-message.h"
+/* Constants for allocating/releasing clients */
+#define QMI_MESSAGE_CTL_ALLOCATE_CID 0x0022
+#define QMI_MESSAGE_CTL_RELEASE_CID 0x0023
+#define QMI_MESSAGE_CTL_ALLOCATE_CID_QRTR 0xFF22
+#define QMI_MESSAGE_CTL_RELEASE_CID_QRTR 0xFF23
+
typedef void (*QmiMessageHandler) (QmiMessage *message,
gpointer user_data);