Skip to contentSkip to conversation

can-bcm: fix minor heap overflow

PATCH Oliver Hartkopp 4 participants 5 messages Nov 10, 2010 – Nov 12, 2010

Subsystems (3)
lore
Share & tools
lore

Oliver Hartkopp

author maintainer
#0 lore raw

On 64-bit platforms the ASCII representation of a pointer may be up to 17 bytes long. This patch increases the length of the buffer accordingly.

http://marc.info/?l=linux-netdev&m=128872251418192&w=2

---

net/can/bcm.c +1 -1
index 08ffe9e..6faa825 100644
@@ -125,7 +125,7 @@ struct bcm_sock {
 	struct list_head tx_ops;
 	unsigned long dropped_usr_msgs;
 	struct proc_dir_entry *bcm_proc_read;
-	char procname [9]; /* pointer printed in ASCII with \0 */
+	char procname [20]; /* pointer printed in ASCII with \0 */
 };
 
 static inline struct bcm_sock *bcm_sk(const struct sock *sk)
#1 lore raw
Quoted 16 lines · Oliver Hartkopp

On 64-bit platforms the ASCII representation of a pointer may be up to 17 bytes long. This patch increases the length of the buffer accordingly.

http://marc.info/?l=linux-netdev&m=128872251418192&w=2

---

net/can/bcm.c +0 -0
index 08ffe9e..6faa825 100644

net/can/bcm.c struct bcm_sock { · line 129

Quoted 6 lines
net/can/bcm.c +1 -1
@@ -125,7 +125,7 @@ struct bcm_sock {
 	struct list_head tx_ops;
 	unsigned long dropped_usr_msgs;
 	struct proc_dir_entry *bcm_proc_read;
-	char procname [9]; /* pointer printed in ASCII with \0 */
+	char procname [20]; /* pointer printed in ASCII with \0 */
 };

If the string may be up to 17 bytes long why are you allocating 20?

Quoted 1 line
net/can/bcm.c +0 -0
 static inline struct bcm_sock *bcm_sk(const struct sock *sk)
#2 lore raw
Quoted 4 lines

If the string may be up to 17 bytes long why are you allocating 20?

In Oliver's defense, this doesn't matter even a little bit. The structure will be allocated with kmalloc-1024 either way.

-Dan

#3 lore raw
Quoted 7 lines · Dan Rosenberg
Quoted 4 lines

If the string may be up to 17 bytes long why are you allocating 20?

In Oliver's defense, this doesn't matter even a little bit. The structure will be allocated with kmalloc-1024 either way.

I agree that its very unlikely to make any difference. I am just curious.

maintainer
#4 lore raw
In reply to Oliver Hartkopp

From: Oliver Hartkopp <[email protected]>
Date: Wed, 10 Nov 2010 23:10:30 +0100

Quoted 8 lines

On 64-bit platforms the ASCII representation of a pointer may be up to 17 bytes long. This patch increases the length of the buffer accordingly.

http://marc.info/?l=linux-netdev&m=128872251418192&w=2

Patch applied, thanks.