Skip to contentSkip to conversation

hwmon: Add ASUS ROG Ryujin III support

PATCH Applied Arie Miller 4 participants 16 messages Aug 12 – Aug 14

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover hwmon: Add ASUS ROG Ryujin III support

Add hardware monitoring support for ASUS ROG Ryujin III coolers.

Compared with the Ryujin II, the Ryujin III uses different offsets in its status reports and a different cooler-duty channel. It also does not expose the Ryujin II's external fan-controller channels. The first patch moves those details into per-device configuration and rejects HID devices without that configuration before it is dereferenced. The second patch adds the Extreme and EVA Edition variants. The third patch, authored by Will Smith, adds the White Edition USB ID. Will confirmed his authorship sign-off and tested that variant on his hardware.

The Ryujin III implementation and White Edition were tested through the linked project pull requests. The EVA Edition hardware was tested by me.

Codex using gpt-5.6-sol assisted with porting the changes to the current hwmon tree, organizing the patch series, updating documentation and commit messages, and running build, checkpatch, Sparse, and Sphinx validation. I reviewed and tested the resulting changes on ROG Ryujin III EVA Edition hardware.

The v3 series passes git diff --check and checkpatch --strict. Its final tree is identical to v2, for which the driver object compiled in-tree with W=1 in both built-in and module configurations, and Sparse reported no findings for either configuration. The range-diff confirms that patches 2 and 3 are unchanged and that patch 4 was folded into patch 1.

Changes in v3:
- Fold the missing driver_data check from patch 4 into patch 1, as requested by Guenter Roeck.
- No source changes from v2.

v2: https://lore.kernel.org/r/[email protected]
v1: https://lore.kernel.org/r/[email protected]

Arie Miller (2):
hwmon: (asus_rog_ryujin) Add per-device configuration
hwmon: (asus_rog_ryujin) Add ROG Ryujin III support

Will Smith (1):
hwmon: (asus_rog_ryujin) Add ROG Ryujin III White Edition

 Documentation/hwmon/asus_rog_ryujin.rst | 25 ++++---
 drivers/hwmon/Kconfig                   |  4 +-
 drivers/hwmon/asus_rog_ryujin.c         | 96 ++++++++++++++++++-------
 3 files changed, 87 insertions(+), 38 deletions(-)

Range-diff against v2:
1: 686fd2251bea ! 1: 35b53d4b4085 hwmon: (asus_rog_ryujin) Add per-device configuration
@@ Commit message
a different report layout or do not include the external fan controller, while preserving the existing Ryujin II 360 behavior.

+ Handles an issue reported by Sashiko where an id could
+ be missing driver_data.
+
+ Link: https://lore.kernel.org/r/[email protected]

Assisted-by Codex:gpt-5.6-sol sparse

@@ drivers/hwmon/asus_rog_ryujin.c: static int rog_ryujin_raw_event(struct hid_devi
if (!completion_done(&priv->cooler_status_received))
complete_all(&priv->cooler_status_received);
@@ drivers/hwmon/asus_rog_ryujin.c: static int rog_ryujin_probe(struct hid_device *hdev, const struct hid_device_id
+ struct rog_ryujin_data *priv;
+ int ret;
+
++ if (!id->driver_data)
++ return -EINVAL;
++
+ priv = devm_kzalloc(&hdev->dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
return -ENOMEM;

priv->hdev = hdev;

2:  68d87330a2f7 = 2:  ce2e2c681daf hwmon: (asus_rog_ryujin) Add ROG Ryujin III support
3:  c3d95809f962 = 3:  2dca57c91535 hwmon: (asus_rog_ryujin) Add ROG Ryujin III White Edition
4:  e9558b907537 < -:  ------------ hwmon: (asus_rog_ryujin) Handle missing driver data

base-commit: 54743b5ab981d686b885c3da639d4ed6cc995e8b

Signature · 1 line
2.55.0
#1 lore raw

PATCH v3 1/3 hwmon: (asus_rog_ryujin) Add per-device configuration

Move model-specific report offsets and capabilities into a device information structure. This prepares the driver for coolers which use a different report layout or do not include the external fan controller, while preserving the existing Ryujin II 360 behavior.

Handles an issue reported by Sashiko where an id could be missing driver_data.

---
 drivers/hwmon/asus_rog_ryujin.c | 75 +++++++++++++++++++++++----------
 1 file changed, 52 insertions(+), 23 deletions(-)
drivers/hwmon/asus_rog_ryujin.c +52 -23
index 10a1f5aca988..80563ce38519 100644
@@ -18,15 +18,25 @@
 #define USB_VENDOR_ID_ASUS_ROG		0x0b05
 #define USB_PRODUCT_ID_RYUJIN_AIO	0x1988	/* ASUS ROG RYUJIN II 360 */
 
+struct rog_ryujin_device_info {
+	u8 temp_offset;
+	u8 pump_speed_offset;
+	u8 fan_speed_offset;
+	u8 duty_channel;
+	bool has_controller;
+};
+
+static const struct rog_ryujin_device_info rog_ryujin_ii_360_info = {
+	.temp_offset = 3,
+	.pump_speed_offset = 5,
+	.fan_speed_offset = 7,
+	.duty_channel = 0,
+	.has_controller = true,
+};
+
 #define STATUS_VALIDITY		1500	/* ms */
 #define MAX_REPORT_LENGTH	65
 
-/* Cooler status report offsets */
-#define RYUJIN_TEMP_SENSOR_1		3
-#define RYUJIN_TEMP_SENSOR_2		4
-#define RYUJIN_PUMP_SPEED		5
-#define RYUJIN_INTERNAL_FAN_SPEED	7
-
 /* Cooler duty report offsets */
 #define RYUJIN_PUMP_DUTY		4
 #define RYUJIN_INTERNAL_FAN_DUTY	5
@@ -81,6 +91,7 @@ static const char *const rog_ryujin_speed_label[] = {
 struct rog_ryujin_data {
 	struct hid_device *hdev;
 	struct device *hwmon_dev;
+	const struct rog_ryujin_device_info *info;
 	/* For reinitializing the completions below */
 	spinlock_t status_report_request_lock;
 	struct completion cooler_status_received;
@@ -112,6 +123,8 @@ static int rog_ryujin_pwm_to_percent(long val)
 static umode_t rog_ryujin_is_visible(const void *data,
 				     enum hwmon_sensor_types type, u32 attr, int channel)
 {
+	const struct rog_ryujin_data *priv = data;
+
 	switch (type) {
 	case hwmon_temp:
 		switch (attr) {
@@ -123,6 +136,8 @@ static umode_t rog_ryujin_is_visible(const void *data,
 		}
 		break;
 	case hwmon_fan:
+		if (channel >= 2 && !priv->info->has_controller)
+			return 0;
 		switch (attr) {
 		case hwmon_fan_label:
 		case hwmon_fan_input:
@@ -132,6 +147,8 @@ static umode_t rog_ryujin_is_visible(const void *data,
 		}
 		break;
 	case hwmon_pwm:
+		if (channel >= 2 && !priv->info->has_controller)
+			return 0;
 		switch (attr) {
 		case hwmon_pwm_input:
 			return 0644;
@@ -198,12 +215,14 @@ static int rog_ryujin_get_status(struct rog_ryujin_data *priv)
 	if (ret < 0)
 		return ret;
 
-	/* Retrieve controller status (speeds) */
-	ret =
-	    rog_ryujin_execute_cmd(priv, get_controller_speed_cmd, GET_CMD_LENGTH,
-				   &priv->controller_status_received);
-	if (ret < 0)
-		return ret;
+	if (priv->info->has_controller) {
+		/* Retrieve controller status (speeds) */
+		ret = rog_ryujin_execute_cmd(priv, get_controller_speed_cmd,
+					     GET_CMD_LENGTH,
+					     &priv->controller_status_received);
+		if (ret < 0)
+			return ret;
+	}
 
 	/* Retrieve cooler duty */
 	ret =
@@ -212,12 +231,14 @@ static int rog_ryujin_get_status(struct rog_ryujin_data *priv)
 	if (ret < 0)
 		return ret;
 
-	/* Retrieve controller duty */
-	ret =
-	    rog_ryujin_execute_cmd(priv, get_controller_duty_cmd, GET_CMD_LENGTH,
-				   &priv->controller_duty_received);
-	if (ret < 0)
-		return ret;
+	if (priv->info->has_controller) {
+		/* Retrieve controller duty */
+		ret = rog_ryujin_execute_cmd(priv, get_controller_duty_cmd,
+					     GET_CMD_LENGTH,
+					     &priv->controller_duty_received);
+		if (ret < 0)
+			return ret;
+	}
 
 	priv->updated = jiffies;
 	return 0;
@@ -289,6 +310,7 @@ static int rog_ryujin_write_fixed_duty(struct rog_ryujin_data *priv, int channel
 			return ret;
 
 		memcpy(set_cmd, set_cooler_duty_cmd, SET_CMD_LENGTH);
+		set_cmd[2] = priv->info->duty_channel;
 
 		/* Cooler duties are set as 0-100% */
 		val = rog_ryujin_pwm_to_percent(val);
@@ -394,10 +416,12 @@ static int rog_ryujin_raw_event(struct hid_device *hdev, struct hid_report *repo
 
 	if (data[1] == RYUJIN_GET_COOLER_STATUS_CMD_RESPONSE) {
 		/* Received coolant temp and speeds of pump and internal fan */
-		priv->temp_input[0] =
-		    data[RYUJIN_TEMP_SENSOR_1] * 1000 + data[RYUJIN_TEMP_SENSOR_2] * 100;
-		priv->speed_input[0] = get_unaligned_le16(data + RYUJIN_PUMP_SPEED);
-		priv->speed_input[1] = get_unaligned_le16(data + RYUJIN_INTERNAL_FAN_SPEED);
+		priv->temp_input[0] = data[priv->info->temp_offset] * 1000 +
+			data[priv->info->temp_offset + 1] * 100;
+		priv->speed_input[0] =
+			get_unaligned_le16(data + priv->info->pump_speed_offset);
+		priv->speed_input[1] =
+			get_unaligned_le16(data + priv->info->fan_speed_offset);
 
 		if (!completion_done(&priv->cooler_status_received))
 			complete_all(&priv->cooler_status_received);
@@ -471,11 +495,15 @@ static int rog_ryujin_probe(struct hid_device *hdev, const struct hid_device_id
 	struct rog_ryujin_data *priv;
 	int ret;
 
+	if (!id->driver_data)
+		return -EINVAL;
+
 	priv = devm_kzalloc(&hdev->dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
 	priv->hdev = hdev;
+	priv->info = (const struct rog_ryujin_device_info *)id->driver_data;
 	hid_set_drvdata(hdev, priv);
 
 	/*
@@ -546,7 +574,8 @@ static void rog_ryujin_remove(struct hid_device *hdev)
 }
 
 static const struct hid_device_id rog_ryujin_table[] = {
-	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS_ROG, USB_PRODUCT_ID_RYUJIN_AIO) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS_ROG, USB_PRODUCT_ID_RYUJIN_AIO),
+	  .driver_data = (kernel_ulong_t)&rog_ryujin_ii_360_info },
 	{ }
 };
 
Signature · 1 line
2.55.0
#2 lore raw

Re: [PATCH v3 1/3] hwmon: (asus_rog_ryujin) Add per-device configuration

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The HID hardware and input streams are started before driver synchronization primitives are initialized, creating a race condition that causes a NULL pointer dereference on device plug. --

--- Patch [1]: [PATCH v3 1/3] hwmon: (asus_rog_ryujin) Add per-device configuration --- commit 5da50001b696b978e4b3741acfab6782c708ed93
Author: Arie Miller <[email protected]>

hwmon: (asus_rog_ryujin) Add per-device configuration

Move model-specific report offsets and capabilities into a device information structure. This prepares the driver for coolers which use a different report layout or do not include the external fan controller.

Quoted 4 lines
drivers/hwmon/asus_rog_ryujin.c +0 -0
index 10a1f5aca988d..80563ce38519d 100644

[ ... ]

Quoted 4 lines
drivers/hwmon/asus_rog_ryujin.c +0 -0
@@ -471,11 +495,15 @@ static int rog_ryujin_probe(struct hid_device *hdev, const struct hid_device_id
 	struct rog_ryujin_data *priv;
 	int ret;
 

drivers/hwmon/asus_rog_ryujin.c static int rog_ryujin_probe(struct hid_device *hdev, const struct hid_device_id · line 507

Quoted 10 lines
drivers/hwmon/asus_rog_ryujin.c +4 -0
+	if (!id->driver_data)
+		return -EINVAL;
+
 	priv = devm_kzalloc(&hdev->dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
 	priv->hdev = hdev;
+	priv->info = (const struct rog_ryujin_device_info *)id->driver_data;
 	hid_set_drvdata(hdev, priv);

[Severity: High]
This is a pre-existing issue, but can the initialization order in this probe function cause a race condition leading to a NULL pointer dereference?

Further down in rog_ryujin_probe(), the driver starts the hardware and opens the stream before initializing the completion structures:

        ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
        ...
        ret = hid_hw_open(hdev);
        ...
        init_completion(&priv->cooler_status_received);

If the device sends a status report immediately after hid_hw_open() is called, rog_ryujin_raw_event() will be invoked to process it. This triggers an attempt to use the uninitialized completion structure:

drivers/hwmon/asus_rog_ryujin.c:rog_ryujin_raw_event() {
        ...
        if (!completion_done(&priv->cooler_status_received))
            complete_all(&priv->cooler_status_received);
        ...
}

Because the priv structure was allocated with devm_kzalloc(), the swait_queue_head inside the completion is initialized to all zeroes.

When complete_all() iterates over the zeroed wait queue, its task_list.next pointer is NULL, which would cause an immediate kernel panic.

Should the init_completion() calls be moved up before hid_hw_start() to ensure they are ready before any reports can arrive?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer
#3 lore raw

Re: [PATCH v3 1/3] hwmon: (asus_rog_ryujin) Add per-device configuration

In reply to Arie Miller
Quoted 7 lines · Arie Miller

Move model-specific report offsets and capabilities into a device information structure. This prepares the driver for coolers which use a different report layout or do not include the external fan controller, while preserving the existing Ryujin II 360 behavior.

Handles an issue reported by Sashiko where an id could be missing driver_data.

This is introduced by this patch and thus irrelevant for the commit message.

Quoted 4 lines

We are too close for me to accept this series without independent
Tested-by: and/or Reviewed-by: feedback. I plan to apply it after the next commit window closes.

I won't mandate that the issues reported by Sashiko are getting fixed, but I wuold strongly suggest for the users of this driver to have a look and consider fixing them. The issues look very real to me.

Thanks,
Guenter

author
#4 lore raw

Re: [PATCH v3 1/3] hwmon: (asus_rog_ryujin) Add per-device configuration

Quoted 3 lines · Guenter Roeck

This is introduced by this patch and thus irrelevant for the commit message.

Do you want me to make a v4 to fix this?

Quoted 8 lines

We are too close for me to accept this series without independent
Tested-by: and/or Reviewed-by: feedback. I plan to apply it after the next commit window closes.

I won't mandate that the issues reported by Sashiko are getting fixed, but I wuold strongly suggest for the users of this driver to have a look and consider fixing them. The issues look very real to me.

I have already started looking into fixing them but since this is my first ever kernel contribution I was avoiding expanding the scope of this series unless you explicitly asked for them to be resolved.

maintainer
#5 lore raw

Re: [PATCH v3 1/3] hwmon: (asus_rog_ryujin) Add per-device configuration

Quoted 7 lines · Arimil
Quoted 3 lines · Guenter Roeck

This is introduced by this patch and thus irrelevant for the commit message.

Do you want me to make a v4 to fix this?

No need; I'll drop it when I apply the patch.

Quoted 4 lines
Quoted 4 lines

We are too close for me to accept this series without independent
Tested-by: and/or Reviewed-by: feedback. I plan to apply it after the next commit window closes.

Quoted 8 lines
Quoted 4 lines

I won't mandate that the issues reported by Sashiko are getting fixed, but I wuold strongly suggest for the users of this driver to have a look and consider fixing them. The issues look very real to me.

I have already started looking into fixing them but since this is my first ever kernel contribution I was avoiding expanding the scope of this series unless you explicitly asked for them to be resolved.

As I said, not as part of this series, and I had hoped that Aleksa would step in.

Thanks,
Guenter

maintainer Reviewed-by on v3 1/3
#6 lore raw

Re: [PATCH v3 1/3] hwmon: (asus_rog_ryujin) Add per-device configuration

In reply to Arie Miller
Quoted 11 lines · Arie Miller

Move model-specific report offsets and capabilities into a device information structure. This prepares the driver for coolers which use a different report layout or do not include the external fan controller, while preserving the existing Ryujin II 360 behavior.

Handles an issue reported by Sashiko where an id could be missing driver_data.

Thanks,
Aleksa

maintainer Applied
#7 lore raw

Re: [PATCH v3 1/3] hwmon: (asus_rog_ryujin) Add per-device configuration

In reply to Arie Miller
Quoted 5 lines · Arie Miller

Move model-specific report offsets and capabilities into a device information structure. This prepares the driver for coolers which use a different report layout or do not include the external fan controller, while preserving the existing Ryujin II 360 behavior.

Quoted 7 lines

Handles an issue reported by Sashiko where an id could be missing driver_data.

Applied.

Thanks,
Guenter

#8 lore raw

PATCH v3 2/3 hwmon: (asus_rog_ryujin) Add ROG Ryujin III support

In reply to Arie Miller

The ROG Ryujin III uses different report offsets and a different cooler-duty channel from the Ryujin II. It also lacks the separate external fan controller supplied with the older model.

Add model data and USB IDs for the Extreme and EVA Edition variants. Skip controller commands and hide the unavailable controller hwmon channels for these devices. Update the driver documentation, Kconfig text, and module description accordingly.

---
 Documentation/hwmon/asus_rog_ryujin.rst | 24 +++++++++++++-----------
 drivers/hwmon/Kconfig                   |  4 ++--
 drivers/hwmon/asus_rog_ryujin.c         | 18 ++++++++++++++++--
 3 files changed, 31 insertions(+), 15 deletions(-)
Documentation/hwmon/asus_rog_ryujin.rst +13 -11
index 9f77da070022..cfdfe3712f19 100644
@@ -6,6 +6,8 @@ Kernel driver asus_rog_ryujin
 Supported devices:
 
 * ASUS ROG RYUJIN II 360
+* ASUS ROG RYUJIN III EXTREME
+* ASUS ROG RYUJIN III EVA EDITION
 
 Author: Aleksa Savic
 
@@ -16,10 +18,10 @@ This driver enables hardware monitoring support for the listed ASUS ROG RYUJIN
 all-in-one CPU liquid coolers. Available sensors are pump, internal and external
 (controller) fan speed in RPM, their duties in PWM, as well as coolant temperature.
 
-Attaching external fans to the controller is optional and allows them to be
-controlled from the device. If not connected, the fan-related sensors will
-report zeroes. The controller is a separate hardware unit that comes bundled
-with the AIO and connects to it to allow fan control.
+The RYUJIN II includes a separate external fan controller. Attaching fans to
+the controller is optional and allows them to be controlled from the device.
+If not connected, the controller-related sensors will report zeroes. The
+RYUJIN III does not expose these controller channels.
 
 The addressable LCD screen is not supported in this driver and should
 be controlled through userspace tools.
@@ -33,15 +35,15 @@ supports hot swapping.
 Sysfs entries
 -------------
 
-=========== =============================================
+=========== ==========================================================
 fan1_input  Pump speed (in rpm)
 fan2_input  Internal fan speed (in rpm)
-fan3_input  External (controller) fan 1 speed (in rpm)
-fan4_input  External (controller) fan 2 speed (in rpm)
-fan5_input  External (controller) fan 3 speed (in rpm)
-fan6_input  External (controller) fan 4 speed (in rpm)
+fan3_input  External (controller) fan 1 speed (in rpm, RYUJIN II only)
+fan4_input  External (controller) fan 2 speed (in rpm, RYUJIN II only)
+fan5_input  External (controller) fan 3 speed (in rpm, RYUJIN II only)
+fan6_input  External (controller) fan 4 speed (in rpm, RYUJIN II only)
 temp1_input Coolant temperature (in millidegrees Celsius)
 pwm1        Pump duty
 pwm2        Internal fan duty
-pwm3        External (controller) fan duty
-=========== =============================================
+pwm3        External (controller) fan duty (RYUJIN II only)
+=========== ==========================================================
drivers/hwmon/Kconfig +2 -2
index 43418633e2e8..81a9a1d40eec 100644
@@ -293,11 +293,11 @@ config SENSORS_ASC7621
 	  will be called asc7621.
 
 config SENSORS_ASUS_ROG_RYUJIN
-	tristate "ASUS ROG RYUJIN II 360 hardware monitoring driver"
+	tristate "ASUS ROG RYUJIN hardware monitoring driver"
 	depends on HID
 	help
 	  If you say yes here you get support for the fans and sensors of
-	  the ASUS ROG RYUJIN II 360 AIO CPU liquid cooler.
+	  supported ASUS ROG RYUJIN II and III AIO CPU liquid coolers.
 
 	  This driver can also be built as a module. If so, the module
 	  will be called asus_rog_ryujin.
drivers/hwmon/asus_rog_ryujin.c +16 -2
index 80563ce38519..79e5b6d6dae0 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * hwmon driver for Asus ROG Ryujin II 360 AIO cooler.
+ * hwmon driver for Asus ROG Ryujin AIO coolers.
  *
  * Copyright 2024 Aleksa Savic <[email protected]>
  */
@@ -17,6 +17,8 @@
 
 #define USB_VENDOR_ID_ASUS_ROG		0x0b05
 #define USB_PRODUCT_ID_RYUJIN_AIO	0x1988	/* ASUS ROG RYUJIN II 360 */
+#define USB_PRODUCT_ID_RYUJIN_III_EXTREME	0x1bcb
+#define USB_PRODUCT_ID_RYUJIN_III_EVA		0x1ade
 
 struct rog_ryujin_device_info {
 	u8 temp_offset;
@@ -34,6 +36,14 @@ static const struct rog_ryujin_device_info rog_ryujin_ii_360_info = {
 	.has_controller = true,
 };
 
+static const struct rog_ryujin_device_info rog_ryujin_iii_info = {
+	.temp_offset = 5,
+	.pump_speed_offset = 7,
+	.fan_speed_offset = 10,
+	.duty_channel = 1,
+	.has_controller = false,
+};
+
 #define STATUS_VALIDITY		1500	/* ms */
 #define MAX_REPORT_LENGTH	65
 
@@ -576,6 +586,10 @@ static void rog_ryujin_remove(struct hid_device *hdev)
 static const struct hid_device_id rog_ryujin_table[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS_ROG, USB_PRODUCT_ID_RYUJIN_AIO),
 	  .driver_data = (kernel_ulong_t)&rog_ryujin_ii_360_info },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS_ROG, USB_PRODUCT_ID_RYUJIN_III_EXTREME),
+	  .driver_data = (kernel_ulong_t)&rog_ryujin_iii_info },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS_ROG, USB_PRODUCT_ID_RYUJIN_III_EVA),
+	  .driver_data = (kernel_ulong_t)&rog_ryujin_iii_info },
 	{ }
 };
 
@@ -605,4 +619,4 @@ module_exit(rog_ryujin_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Aleksa Savic <[email protected]>");
-MODULE_DESCRIPTION("Hwmon driver for Asus ROG Ryujin II 360 AIO cooler");
+MODULE_DESCRIPTION("Hwmon driver for Asus ROG Ryujin AIO coolers");
Signature · 1 line
2.55.0
#9 lore raw

Re: [PATCH v3 2/3] hwmon: (asus_rog_ryujin) Add ROG Ryujin III support

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

Pre-existing issues:
- [Critical] Hardware transport is started before synchronization primitives are initialized, leading to a NULL pointer dereference.
- [High] Missing bounds check on HID report size leads to kernel memory information leak.
- [High] Ineffective spinlock usage causes data races and corrupted completion state.
--

--- Patch [2]: [PATCH v3 2/3] hwmon: (asus_rog_ryujin) Add ROG Ryujin III support --- commit 38401fc658552e2aee59237664fe94f5ef49d39c
Author: Arie Miller <[email protected]>

hwmon: (asus_rog_ryujin) Add ROG Ryujin III support

The ROG Ryujin III uses different report offsets and a different cooler-duty channel from the Ryujin II. It also lacks the separate external fan controller supplied with the older model.

Quoted 4 lines
drivers/hwmon/asus_rog_ryujin.c +0 -0
index 80563ce38519d..79e5b6d6dae0a 100644

[ ... ]

drivers/hwmon/asus_rog_ryujin.c static const struct rog_ryujin_device_info rog_ryujin_ii_360_info = { · line 42

Quoted 8 lines
drivers/hwmon/asus_rog_ryujin.c +4 -0
@@ -34,6 +36,14 @@ static const struct rog_ryujin_device_info rog_ryujin_ii_360_info = {
 	.has_controller = true,
 };
 
+static const struct rog_ryujin_device_info rog_ryujin_iii_info = {
+	.temp_offset = 5,
+	.pump_speed_offset = 7,
+	.fan_speed_offset = 10,

[Severity: High]
This isn't a bug introduced by this patch, but does this driver check the size of the incoming HID report before parsing it?

In rog_ryujin_raw_event(), the driver dynamically accesses payload offsets without validating against the received report size:

	priv->speed_input[1] =
		get_unaligned_le16(data + priv->info->fan_speed_offset);

If a malicious or buggy USB device sends a HID report shorter than the expected length (e.g., 1 byte), this code would unconditionally access memory up to the offset. Since the underlying HID transport buffer is dynamically allocated to at least 64 bytes (HID_MIN_BUFFER_SIZE), an out-of-bounds page fault wouldn't occur, but uninitialized buffer bytes could be parsed as sensor values and exposed to userspace via hwmon sysfs attributes.

Could we add a size check at the beginning of rog_ryujin_raw_event() to prevent leaking kernel memory information?

Quoted 4 lines
drivers/hwmon/asus_rog_ryujin.c +4 -0
+	.duty_channel = 1,
+	.has_controller = false,
+};
+

[ ... ]

drivers/hwmon/asus_rog_ryujin.c module_exit(rog_ryujin_exit); · line 622

Quoted 6 lines
drivers/hwmon/asus_rog_ryujin.c +1 -1
@@ -605,4 +619,4 @@ module_exit(rog_ryujin_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Aleksa Savic <[email protected]>");
-MODULE_DESCRIPTION("Hwmon driver for Asus ROG Ryujin II 360 AIO cooler");
+MODULE_DESCRIPTION("Hwmon driver for Asus ROG Ryujin AIO coolers");

[Severity: Critical]
This is a pre-existing issue, but is the initialization order safe in rog_ryujin_probe()?

The hardware transport is enabled and opened before initializing the completion structures used in the raw event handler:

	ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
	...
	ret = hid_hw_open(hdev);
	...
	init_completion(&priv->cooler_status_received);

If a report arrives immediately after hid_hw_open(), rog_ryujin_raw_event() can fire and call complete_all() on a zero-allocated struct completion.

The wait.head list_head inside the completion is uninitialized, which could cause __wake_up_locked() to dereference a NULL pointer and trigger a kernel panic.

Should init_completion() be moved before the hardware transport is started?

[Severity: High]
This is a pre-existing issue, but does the spinlock usage correctly serialize against the raw event handler?

In rog_ryujin_execute_cmd(), the spinlock is acquired to serialize against the raw event handler:

	spin_lock_bh(&priv->status_report_request_lock);
	reinit_completion(status_completion);
	spin_unlock_bh(&priv->status_report_request_lock);

However, rog_ryujin_raw_event() modifies the completion state concurrently without acquiring this protective spinlock:

	if (!completion_done(&priv->cooler_status_received))
		complete_all(&priv->cooler_status_received);

If a device report arrives on another CPU exactly as execute_cmd() is calling reinit_completion() (which sets done = 0), this lack of mutual exclusion allows reinit_completion() to race with complete_all().

Could this corrupt the completion count and cause the driver to sleep until timeout?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
maintainer Reviewed-by on v3 2/3
#10 lore raw

Re: [PATCH v3 2/3] hwmon: (asus_rog_ryujin) Add ROG Ryujin III support

In reply to Arie Miller
Quoted 4 lines · Arie Miller

The ROG Ryujin III uses different report offsets and a different cooler-duty channel from the Ryujin II. It also lacks the separate external fan controller supplied with the older model.

Quoted 8 lines

Add model data and USB IDs for the Extreme and EVA Edition variants. Skip controller commands and hide the unavailable controller hwmon channels for these devices. Update the driver documentation, Kconfig text, and module description accordingly.

Thanks,
Aleksa

maintainer Applied
#11 lore raw

Re: [PATCH v3 2/3] hwmon: (asus_rog_ryujin) Add ROG Ryujin III support

In reply to Arie Miller
Quoted 9 lines · Arie Miller

The ROG Ryujin III uses different report offsets and a different cooler-duty channel from the Ryujin II. It also lacks the separate external fan controller supplied with the older model.

Add model data and USB IDs for the Extreme and EVA Edition variants. Skip controller commands and hide the unavailable controller hwmon channels for these devices. Update the driver documentation, Kconfig text, and module description accordingly.

Quoted 4 lines

Applied.

Thanks,
Guenter

#12 lore raw

PATCH v3 3/3 hwmon: (asus_rog_ryujin) Add ROG Ryujin III White Edition

In reply to Arie Miller

From: Will Smith <[email protected]>

The ROG Ryujin III White Edition uses the same report layout as the other supported Ryujin III variants. Add its USB device ID and list it in the driver documentation.

The device was tested with the driver on the author's hardware.

---
 Documentation/hwmon/asus_rog_ryujin.rst | 1 +
 drivers/hwmon/asus_rog_ryujin.c         | 3 +++
 2 files changed, 4 insertions(+)
Documentation/hwmon/asus_rog_ryujin.rst +1 -0
index cfdfe3712f19..b0d7ce8dd921 100644
@@ -8,6 +8,7 @@ Supported devices:
 * ASUS ROG RYUJIN II 360
 * ASUS ROG RYUJIN III EXTREME
 * ASUS ROG RYUJIN III EVA EDITION
+* ASUS ROG RYUJIN III WHITE EDITION
 
 Author: Aleksa Savic
 
drivers/hwmon/asus_rog_ryujin.c +3 -0
index 79e5b6d6dae0..702edb831394 100644
@@ -19,6 +19,7 @@
 #define USB_PRODUCT_ID_RYUJIN_AIO	0x1988	/* ASUS ROG RYUJIN II 360 */
 #define USB_PRODUCT_ID_RYUJIN_III_EXTREME	0x1bcb
 #define USB_PRODUCT_ID_RYUJIN_III_EVA		0x1ade
+#define USB_PRODUCT_ID_RYUJIN_III_WHITE		0x1ada
 
 struct rog_ryujin_device_info {
 	u8 temp_offset;
@@ -590,6 +591,8 @@ static const struct hid_device_id rog_ryujin_table[] = {
 	  .driver_data = (kernel_ulong_t)&rog_ryujin_iii_info },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS_ROG, USB_PRODUCT_ID_RYUJIN_III_EVA),
 	  .driver_data = (kernel_ulong_t)&rog_ryujin_iii_info },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS_ROG, USB_PRODUCT_ID_RYUJIN_III_WHITE),
+	  .driver_data = (kernel_ulong_t)&rog_ryujin_iii_info },
 	{ }
 };
 
Signature · 1 line
2.55.0
#13 lore raw

Re: [PATCH v3 3/3] hwmon: (asus_rog_ryujin) Add ROG Ryujin III White Edition

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing bounds check on incoming HID report data in raw_event callback, leading to out-of-bounds read. --

--- Patch [3]: [PATCH v3 3/3] hwmon: (asus_rog_ryujin) Add ROG Ryujin III White Edition --- commit c24d3645c70fad1763a76ddee1293e1040bce990
Author: Will Smith <[email protected]>
Subject: hwmon: (asus_rog_ryujin) Add ROG Ryujin III White Edition

This commit adds support for the ROG Ryujin III White Edition cooler by adding its USB product ID to the asus_rog_ryujin driver. It utilizes the same report layout as the other Ryujin III variants.

Quoted 4 lines
drivers/hwmon/asus_rog_ryujin.c +0 -0
index 79e5b6d6dae0a..702edb8313945 100644

[ ... ]

drivers/hwmon/asus_rog_ryujin.c static const struct hid_device_id rog_ryujin_table[] = { · line 595

Quoted 6 lines
drivers/hwmon/asus_rog_ryujin.c +2 -0
@@ -590,6 +591,8 @@ static const struct hid_device_id rog_ryujin_table[] = {
 	  .driver_data = (kernel_ulong_t)&rog_ryujin_iii_info },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS_ROG, USB_PRODUCT_ID_RYUJIN_III_EVA),
 	  .driver_data = (kernel_ulong_t)&rog_ryujin_iii_info },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS_ROG, USB_PRODUCT_ID_RYUJIN_III_WHITE),
+	  .driver_data = (kernel_ulong_t)&rog_ryujin_iii_info },

[Severity: High]
This is a pre-existing issue, but does adding this new device expose it to an out-of-bounds read in rog_ryujin_raw_event()?

If the new device sends a short report or has a short report descriptor, rog_ryujin_raw_event() accesses data buffers without checking the size first:

drivers/hwmon/asus_rog_ryujin.c:rog_ryujin_raw_event() {
	struct rog_ryujin_data *priv = hid_get_drvdata(hdev);

	if (data[0] != RYUJIN_CMD_PREFIX)
		return 0;

...
}

Would a malicious USB device sending a short report trigger a slab out-of-bounds read here, or when reading larger offsets like priv->info->fan_speed_offset? Should there be a size validation check added to the raw event handler?

Quoted 2 lines
drivers/hwmon/asus_rog_ryujin.c +0 -0
 	{ }
 };
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
maintainer Reviewed-by on v3 3/3
#14 lore raw

Re: [PATCH v3 3/3] hwmon: (asus_rog_ryujin) Add ROG Ryujin III White Edition

In reply to Arie Miller
Quoted 42 lines · Arie Miller

From: Will Smith <[email protected]>

The ROG Ryujin III White Edition uses the same report layout as the other supported Ryujin III variants. Add its USB device ID and list it in the driver documentation.

The device was tested with the driver on the author's hardware.

---
  Documentation/hwmon/asus_rog_ryujin.rst | 1 +
  drivers/hwmon/asus_rog_ryujin.c         | 3 +++
  2 files changed, 4 insertions(+)
Documentation/hwmon/asus_rog_ryujin.rst +1 -0
index cfdfe3712f19..b0d7ce8dd921 100644
@@ -8,6 +8,7 @@ Supported devices:
  * ASUS ROG RYUJIN II 360
  * ASUS ROG RYUJIN III EXTREME
  * ASUS ROG RYUJIN III EVA EDITION
+* ASUS ROG RYUJIN III WHITE EDITION
 
  Author: Aleksa Savic
 
drivers/hwmon/asus_rog_ryujin.c +1 -0
index 79e5b6d6dae0..702edb831394 100644
@@ -19,6 +19,7 @@
  #define USB_PRODUCT_ID_RYUJIN_AIO	0x1988	/* ASUS ROG RYUJIN II 360 */
  #define USB_PRODUCT_ID_RYUJIN_III_EXTREME	0x1bcb
  #define USB_PRODUCT_ID_RYUJIN_III_EVA		0x1ade
+#define USB_PRODUCT_ID_RYUJIN_III_WHITE		0x1ada
 
  struct rog_ryujin_device_info {
  	u8 temp_offset;

drivers/hwmon/asus_rog_ryujin.c static const struct hid_device_id rog_ryujin_table[] = { · line 598

Quoted 8 lines
drivers/hwmon/asus_rog_ryujin.c +2 -0
@@ -590,6 +591,8 @@ static const struct hid_device_id rog_ryujin_table[] = {
  	  .driver_data = (kernel_ulong_t)&rog_ryujin_iii_info },
  	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS_ROG, USB_PRODUCT_ID_RYUJIN_III_EVA),
  	  .driver_data = (kernel_ulong_t)&rog_ryujin_iii_info },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS_ROG, USB_PRODUCT_ID_RYUJIN_III_WHITE),
+	  .driver_data = (kernel_ulong_t)&rog_ryujin_iii_info },
  	{ }
  };
 

Thanks,
Aleksa

maintainer Applied
#15 lore raw

Re: [PATCH v3 3/3] hwmon: (asus_rog_ryujin) Add ROG Ryujin III White Edition

In reply to Arie Miller
Quoted 6 lines · Arie Miller

From: Will Smith <[email protected]>

The ROG Ryujin III White Edition uses the same report layout as the other supported Ryujin III variants. Add its USB device ID and list it in the driver documentation.

Quoted 7 lines

The device was tested with the driver on the author's hardware.

Applied.

Thanks,
Guenter