Skip to contentSkip to conversation

sound/isa/wavefront: copy userspace array safely

PATCH In review Philipp Stanner 2 participants 3 messages Nov 2, 2023 – Nov 3, 2023 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sound/isa/wavefront: copy userspace array safely

wavefront_fx.c utilizes memdup_user() to copy a userspace array. This does not check for an overflow.

Use the new wrapper memdup_array_user() to copy the array more safely.

---
 sound/isa/wavefront/wavefront_fx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
sound/isa/wavefront/wavefront_fx.c +3 -3
index 3c21324b2a0e..0273b7dfaf12 100644
@@ -191,9 +191,9 @@ snd_wavefront_fx_ioctl (struct snd_hwdep *sdev, struct file *file,
 					    "> 512 bytes to FX\n");
 				return -EIO;
 			}
-			page_data = memdup_user((unsigned char __user *)
-						r.data[3],
-						r.data[2] * sizeof(short));
+			page_data = memdup_array_user((unsigned char __user *)
+						      r.data[3],
+						      r.data[2], sizeof(short));
 			if (IS_ERR(page_data))
 				return PTR_ERR(page_data);
 			pd = page_data;
Signature · 1 line
2.41.0
#1 lore raw
Quoted 3 lines · Philipp Stanner

wavefront_fx.c utilizes memdup_user() to copy a userspace array. This does not check for an overflow.

There is a check above the memdup_user() call; it's at most 512 bytes.

Quoted 4 lines

Use the new wrapper memdup_array_user() to copy the array more safely.

Although the check is already present, it's still better to use the new helper, so I applied the patch now.

thanks,

Takashi

#2 lore raw
Quoted 10 lines · Takashi Iwai
Quoted 3 lines · Philipp Stanner

wavefront_fx.c utilizes memdup_user() to copy a userspace array. This does not check for an overflow.

There is a check above the memdup_user() call; it's at most 512 bytes.

Quoted 7 lines
Quoted 4 lines

Use the new wrapper memdup_array_user() to copy the array more safely.

Although the check is already present, it's still better to use the new helper, so I applied the patch now.

... and the helper is available only on Linus tree for now, so I postpone after 6.7-rc1 release, so that we can have a solid base.

Takashi