Skip to contentSkip to conversation

Patch "staging: rtl: fix possible NULL pointer dereference" has been added to the 4.10-stable tree

PATCH [email protected] 1 participant 1 message Mar 8, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

staging: rtl: fix possible NULL pointer dereference

to the 4.10-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
staging-rtl-fix-possible-null-pointer-dereference.patch
and it can be found in the queue-4.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 6e017006022abfea5d2466cad936065f45763ad1 Mon Sep 17 00:00:00 2001

From: Arnd Bergmann <[email protected]>
Date: Wed, 11 Jan 2017 15:53:08 +0100
Subject: staging: rtl: fix possible NULL pointer dereference

From: Arnd Bergmann <[email protected]>

commit 6e017006022abfea5d2466cad936065f45763ad1 upstream.

gcc-7 detects that wlanhdr_to_ethhdr() in two drivers calls memcpy() with a destination argument that an earlier function call may have set to NULL:

staging/rtl8188eu/core/rtw_recv.c: In function 'wlanhdr_to_ethhdr':
staging/rtl8188eu/core/rtw_recv.c:1318:2: warning: argument 1 null where non-null expected [-Wnonnull] staging/rtl8712/rtl871x_recv.c: In function 'r8712_wlanhdr_to_ethhdr':
staging/rtl8712/rtl871x_recv.c:649:2: warning: argument 1 null where non-null expected [-Wnonnull]

I'm fixing this by adding a NULL pointer check and returning failure from the function, which is hopefully already handled properly.

This seems to date back to when the drivers were originally added, so backporting the fix to stable seems appropriate. There are other related realtek drivers in the kernel, but none of them contain a function with a similar name or produce this warning.

Fixes 1cc18a22b96b ("staging: r8188eu: Add files for new driver - part 5")
Fixes 2865d42c78a9 ("staging: r8712u: Add the new driver to the mainline kernel")
---
 drivers/staging/rtl8188eu/core/rtw_recv.c |    3 +++
 drivers/staging/rtl8712/rtl871x_recv.c    |    7 ++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/staging/rtl8188eu/core/rtw_recv.c +3 -0
@@ -1349,6 +1349,9 @@ static int wlanhdr_to_ethhdr(struct recv
 		ptr = recvframe_pull(precvframe, (rmv_len-sizeof(struct ethhdr) + (bsnaphdr ? 2 : 0)));
 	}
 
+	if (!ptr)
+		return _FAIL;
+
 	memcpy(ptr, pattrib->dst, ETH_ALEN);
 	memcpy(ptr+ETH_ALEN, pattrib->src, ETH_ALEN);
 
drivers/staging/rtl8712/rtl871x_recv.c +6 -1
@@ -640,11 +640,16 @@ sint r8712_wlanhdr_to_ethhdr(union recv_
 		/* append rx status for mp test packets */
 		ptr = recvframe_pull(precvframe, (rmv_len -
 		      sizeof(struct ethhdr) + 2) - 24);
+		if (!ptr)
+			return _FAIL;
 		memcpy(ptr, get_rxmem(precvframe), 24);
 		ptr += 24;
-	} else
+	} else {
 		ptr = recvframe_pull(precvframe, (rmv_len -
 		      sizeof(struct ethhdr) + (bsnaphdr ? 2 : 0)));
+		if (!ptr)
+			return _FAIL;
+	}
 
 	memcpy(ptr, pattrib->dst, ETH_ALEN);
 	memcpy(ptr + ETH_ALEN, pattrib->src, ETH_ALEN);

Patches currently in stable-queue which might be from [email protected] are

queue-4.10/staging-rtl-fix-possible-null-pointer-dereference.patch