Skip to contentSkip to conversation

kni: fix possible buffer overflow

PATCH Applied Ferruh Yigit 3 participants 5 messages Jul 11, 2019 – Jul 19, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kni: fix possible buffer overflow

'kni_net_rx_lo_fifo()' can get segmented buffers, using 'pkt_len' for that case will be wrong and some values can cause buffer overflow in destination mbuf data.

---
 kernel/linux/kni/kni_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/linux/kni/kni_net.c +1 -1
index ad8365877..84341ac92 100644
@@ -435,7 +435,7 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 		/* Copy mbufs */
 		for (i = 0; i < num; i++) {
 			kva = pa2kva(kni->pa[i]);
-			len = kva->pkt_len;
+			len = kva->data_len;
 			data_kva = kva2data_kva(kva);
 			kni->va[i] = pa2va(kni->pa[i], kva);
 
Signature · 1 line
2.21.0
Acked-by on v1 1/1
#1 lore raw
Quoted 14 lines · On Thu, 11 Jul 2019 13:35:07 +0100 Ferruh Yigit <[email protected]> wrote:

'kni_net_rx_lo_fifo()' can get segmented buffers, using 'pkt_len' for that case will be wrong and some values can cause buffer overflow in destination mbuf data.

---
 kernel/linux/kni/kni_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/linux/kni/kni_net.c +0 -0
index ad8365877..84341ac92 100644

kernel/linux/kni/kni_net.c kni_net_rx_lo_fifo(struct kni_dev *kni) · line 441

Quoted 8 lines
kernel/linux/kni/kni_net.c +1 -1
@@ -435,7 +435,7 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 		/* Copy mbufs */
 		for (i = 0; i < num; i++) {
 			kva = pa2kva(kni->pa[i]);
-			len = kva->pkt_len;
+			len = kva->data_len;
 			data_kva = kva2data_kva(kva);
 			kni->va[i] = pa2va(kni->pa[i], kva);
 
#3 lore raw

18/07/2019 23:24, Thomas Monjalon:

Quoted 8 lines

11/07/2019 17:33, Stephen Hemminger:

Quoted 7 lines
Quoted 4 lines · On Thu, 11 Jul 2019 13:35:07 +0100 Ferruh Yigit <[email protected]> wrote:

'kni_net_rx_lo_fifo()' can get segmented buffers, using 'pkt_len' for that case will be wrong and some values can cause buffer overflow in destination mbuf data.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Applied, thanks

I hope these lines are correct:

Fixes d89a58dfe90b ("kni: support chained mbufs")
#4 lore raw
Quoted 11 lines · Thomas Monjalon

18/07/2019 23:24, Thomas Monjalon:

Quoted 10 lines

11/07/2019 17:33, Stephen Hemminger:

Quoted 9 lines
Quoted 5 lines · On Thu, 11 Jul 2019 13:35:07 +0100 Ferruh Yigit <[email protected]> wrote:

'kni_net_rx_lo_fifo()' can get segmented buffers, using 'pkt_len' for that case will be wrong and some values can cause buffer overflow in destination mbuf data.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Applied, thanks

I hope these lines are correct:

Fixes d89a58dfe90b ("kni: support chained mbufs")

Thanks for updating it, even before this commit the related code was wrong I think, but agree that this commit should have fixed it, so agreed with the fixes line.