ALSA: dice: fix array limits in dice_proc_read()
Subsystems (3)
PATCH 1/1 ALSA: dice: fix array limits in dice_proc_read()
The array limits are supposed to be in units of u32 instead of in bytes. The current code has a potential array overflow.
sound/firewire/dice.c +2 -2
@@ -1019,7 +1019,7 @@ static void dice_proc_read(struct snd_info_entry *entry,if (dice_proc_read_mem (dice, &tx_rx_header, sections[2 ],2 ) <0 )return ; - quadlets =min_t (u32, tx_rx_header.size,sizeof (buf.tx)); + quadlets =min_t (u32, tx_rx_header.size,sizeof (buf.tx) /4 );for (stream =0 ; stream < tx_rx_header.number; ++stream) { if (dice_proc_read_mem(dice, &buf.tx, sections[2] + 2 + stream * tx_rx_header.size,
@@ -1045,7 +1045,7 @@ static void dice_proc_read(struct snd_info_entry *entry,if (dice_proc_read_mem (dice, &tx_rx_header, sections[4 ],2 ) <0 )return ; - quadlets =min_t (u32, tx_rx_header.size,sizeof (buf.rx)); + quadlets =min_t (u32, tx_rx_header.size,sizeof (buf.rx) /4 );for (stream =0 ; stream < tx_rx_header.number; ++stream) { if (dice_proc_read_mem(dice, &buf.rx, sections[4] + 2 + stream * tx_rx_header.size,
Quoted 5 lines · Dan Carpenter
The array limits are supposed to be in units of u32 instead of in bytes. The current code has a potential array overflow.
Fixes c614475b0ea9 ('ALSA: dice: add a proc file to show device information')Signed-off-by Dan Carpenter <[email protected]>
Quoted 22 lines
sound/firewire/dice.c +2
-2@@ -1019,7 +1019,7 @@ static void dice_proc_read(struct snd_info_entry *entry,if (dice_proc_read_mem (dice, &tx_rx_header, sections[2 ],2 ) <0 )return ; - quadlets =min_t (u32, tx_rx_header.size,sizeof (buf.tx)); + quadlets =min_t (u32, tx_rx_header.size,sizeof (buf.tx) /4 );for (stream =0 ; stream < tx_rx_header.number; ++stream) { if (dice_proc_read_mem(dice, &buf.tx, sections[2] + 2 + stream * tx_rx_header.size,@@ -1045,7 +1045,7 @@ static void dice_proc_read(struct snd_info_entry *entry,if (dice_proc_read_mem (dice, &tx_rx_header, sections[4 ],2 ) <0 )return ; - quadlets =min_t (u32, tx_rx_header.size,sizeof (buf.rx)); + quadlets =min_t (u32, tx_rx_header.size,sizeof (buf.rx) /4 );for (stream =0 ; stream < tx_rx_header.number; ++stream) { if (dice_proc_read_mem(dice, &buf.rx, sections[4] + 2 + stream * tx_rx_header.size,
Takashi Iwai
AppliedAt Fri, 29 Nov 2013 11:14:09 +0300,
Quoted 6 lines · Dan Carpenter
The array limits are supposed to be in units of u32 instead of in bytes. The current code has a potential array overflow.
Fixes c614475b0ea9 ('ALSA: dice: add a proc file to show device information')Signed-off-by Dan Carpenter <[email protected]>
Thanks, applied.
Takashi
Quoted 24 lines
sound/firewire/dice.c +2
-2@@ -1019,7 +1019,7 @@ static void dice_proc_read(struct snd_info_entry *entry,if (dice_proc_read_mem (dice, &tx_rx_header, sections[2 ],2 ) <0 )return ; - quadlets =min_t (u32, tx_rx_header.size,sizeof (buf.tx)); + quadlets =min_t (u32, tx_rx_header.size,sizeof (buf.tx) /4 );for (stream =0 ; stream < tx_rx_header.number; ++stream) { if (dice_proc_read_mem(dice, &buf.tx, sections[2] + 2 + stream * tx_rx_header.size,@@ -1045,7 +1045,7 @@ static void dice_proc_read(struct snd_info_entry *entry,if (dice_proc_read_mem (dice, &tx_rx_header, sections[4 ],2 ) <0 )return ; - quadlets =min_t (u32, tx_rx_header.size,sizeof (buf.rx)); + quadlets =min_t (u32, tx_rx_header.size,sizeof (buf.rx) /4 );for (stream =0 ; stream < tx_rx_header.number; ++stream) { if (dice_proc_read_mem(dice, &buf.rx, sections[4] + 2 + stream * tx_rx_header.size,
Am 29.11.2013 09:14, schrieb Dan Carpenter:
Quoted 11 lines
The array limits are supposed to be in units of u32 instead of in bytes. The current code has a potential array overflow.
Fixes c614475b0ea9 ('ALSA: dice: add a proc file to show device information')Signed-off-by Dan Carpenter <[email protected]>sound/firewire/dice.c +0
-0
sound/firewire/dice.c static void dice_proc_read(struct snd_info_entry *entry, · line 1022
Quoted 5 lines
sound/firewire/dice.c +1
-1@@ -1019,7 +1019,7 @@ static void dice_proc_read(struct snd_info_entry *entry,if (dice_proc_read_mem (dice, &tx_rx_header, sections[2 ],2 ) <0 )return ; - quadlets =min_t (u32, tx_rx_header.size,sizeof (buf.tx)); + quadlets =min_t (u32, tx_rx_header.size,sizeof (buf.tx) /4 );
it is a bit late but ...
sizeof(buf.tx) / 4 looks like ARRAY_SIZE(buf.tx)
If yes i suggest ARRAY_SIZE() because it gets rid of the "magic" 4.
re,
wh
Quoted 17 lines
sound/firewire/dice.c +1
-2for (stream =0 ; stream < tx_rx_header.number; ++stream) { if (dice_proc_read_mem(dice, &buf.tx, sections[2] + 2 + stream * tx_rx_header.size,@@ -1045,7 +1045,7 @@ static void dice_proc_read(struct snd_info_entry *entry,if (dice_proc_read_mem (dice, &tx_rx_header, sections[4 ],2 ) <0 )return ; - quadlets =min_t (u32, tx_rx_header.size,sizeof (buf.rx)); + quadlets =min_t (u32, tx_rx_header.size,sizeof (buf.rx) /4 );for (stream =0 ; stream < tx_rx_header.number; ++stream) { if (dice_proc_read_mem(dice, &buf.rx, sections[4] + 2 + stream * tx_rx_header.size, --To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
At Fri, 29 Nov 2013 10:48:28 +0100,
Quoted 16 lines · walter harms
Am 29.11.2013 09:14, schrieb Dan Carpenter:
Quoted 12 lines
The array limits are supposed to be in units of u32 instead of in bytes. The current code has a potential array overflow.
Fixes c614475b0ea9 ('ALSA: dice: add a proc file to show device information')Signed-off-by Dan Carpenter <[email protected]>sound/firewire/dice.c +0
-0@@ -1019,7 +1019,7 @@ static void dice_proc_read(struct snd_info_entry *entry,
Quoted 8 lines
sound/firewire/dice.c static void dice_proc_read(struct snd_info_entry *entry, · line 1022
Quoted 4 lines
sound/firewire/dice.c +1
-1if (dice_proc_read_mem (dice, &tx_rx_header, sections[2 ],2 ) <0 )return ; - quadlets =min_t (u32, tx_rx_header.size,sizeof (buf.tx)); + quadlets =min_t (u32, tx_rx_header.size,sizeof (buf.tx) /4 );it is a bit late but ...
sizeof(buf.tx) / 4 looks like
ARRAY_SIZE(buf.tx)
Not in this case :)
I thought of it at first, too, but understood it after reading the code.
Takashi
Quoted 25 lines
If yes i suggest
ARRAY_SIZE()because it gets rid of the "magic" 4.re,
whQuoted 17 lines
sound/firewire/dice.c +1
-2for (stream =0 ; stream < tx_rx_header.number; ++stream) { if (dice_proc_read_mem(dice, &buf.tx, sections[2] + 2 + stream * tx_rx_header.size,@@ -1045,7 +1045,7 @@ static void dice_proc_read(struct snd_info_entry *entry,if (dice_proc_read_mem (dice, &tx_rx_header, sections[4 ],2 ) <0 )return ; - quadlets =min_t (u32, tx_rx_header.size,sizeof (buf.rx)); + quadlets =min_t (u32, tx_rx_header.size,sizeof (buf.rx) /4 );for (stream =0 ; stream < tx_rx_header.number; ++stream) { if (dice_proc_read_mem(dice, &buf.rx, sections[4] + 2 + stream * tx_rx_header.size, --To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html