Prechádzať zdrojové kódy

Fixed addr_limit error for newer versions of kernel > (5,10,0).

using get_fs and set_fs limited for hardcodingly access for fs members are restricted memory addresses.

thats why I changed them with force_uaccess_* methods.
Suleyman Poyraz 4 rokov pred
rodič
commit
51bd3dd777
4 zmenil súbory, kde vykonal 21 pridanie a 29 odobranie
  1. 3 4
      core/rtw_btcoex.c
  2. 4 5
      core/rtw_wlan_util.c
  3. 6 10
      os_dep/linux/os_intfs.c
  4. 8 10
      os_dep/osdep_service.c

+ 3 - 4
core/rtw_btcoex.c

@@ -1475,12 +1475,11 @@ u8 rtw_btcoex_sendmsgbysocket(_adapter *padapter, u8 *msg, u8 msg_size, bool for
 	udpmsg.msg_controllen = 0;
 	udpmsg.msg_flags	= MSG_DONTWAIT | MSG_NOSIGNAL;
 
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 	oldfs = get_fs();
 	set_fs(KERNEL_DS);
 #else
-	oldfs = (current_thread_info()->addr_limit);
-	current_thread_info()->addr_limit = (MAKE_MM_SEG(-1UL));
+	oldfs = force_uaccess_begin();
 #endif
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0))
@@ -1491,7 +1490,7 @@ u8 rtw_btcoex_sendmsgbysocket(_adapter *padapter, u8 *msg, u8 msg_size, bool for
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 	set_fs(oldfs);
 #else
-	current_thread_info()->addr_limit = (oldfs);
+	force_uaccess_end(oldfs);
 #endif
 	if (error < 0) {
 		RTW_INFO("Error when sendimg msg, error:%d\n", error);

+ 4 - 5
core/rtw_wlan_util.c

@@ -4751,12 +4751,11 @@ int rtw_dev_nlo_info_set(struct pno_nlo_info *nlo_info, pno_ssid_t *ssid,
 		return 0;
 	}
 
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0))
 	fs = get_fs();
 	set_fs(KERNEL_DS);
 #else
-	fs = (current_thread_info()->addr_limit);
-	current_thread_info()->addr_limit = (MAKE_MM_SEG(-1UL));
+	fs = force_uaccess_begin();
 #endif
 
 	source = rtw_zmalloc(2048);
@@ -4767,10 +4766,10 @@ int rtw_dev_nlo_info_set(struct pno_nlo_info *nlo_info, pno_ssid_t *ssid,
 		rtw_mfree(source, 2048);
 	}
 
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 	set_fs(fs);
 #else
-	current_thread_info()->addr_limit = (fs);
+	force_uaccess_end(fs);
 #endif
 	filp_close(fp, NULL);
 

+ 6 - 10
os_dep/linux/os_intfs.c

@@ -4012,8 +4012,7 @@ static int route_dump(u32 *gw_addr , int *gw_index)
 	oldfs = get_fs();
 	set_fs(KERNEL_DS);
 #else
-	oldfs = (current_thread_info()->addr_limit);
-	current_thread_info()->addr_limit = ((mm_segment_t) { (-1UL) });
+	oldfs = force_uaccess_begin();
 #endif
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0))
 	err = sock_sendmsg(sock, &msg);
@@ -4023,7 +4022,7 @@ static int route_dump(u32 *gw_addr , int *gw_index)
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 	set_fs(oldfs);
 #else
-	current_thread_info()->addr_limit = (oldfs);
+	force_uaccess_end(oldfs);
 #endif
 
 	if (err < 0)
@@ -4053,8 +4052,7 @@ restart:
 		oldfs = get_fs();
 		set_fs(KERNEL_DS);
 #else
-	oldfs = (current_thread_info()->addr_limit);
-	current_thread_info()->addr_limit = ((mm_segment_t) { (-1UL) });
+		oldfs = force_uaccess_begin();
 #endif
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))
 		err = sock_recvmsg(sock, &msg, MSG_DONTWAIT);
@@ -4064,7 +4062,7 @@ restart:
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 		set_fs(oldfs);
 #else
-		current_thread_info()->addr_limit = (oldfs);
+		force_uaccess_end(oldfs);
 
 #endif
 
@@ -4141,8 +4139,7 @@ done:
 		oldfs = get_fs();
 		set_fs(KERNEL_DS);
 #else
-		oldfs = (current_thread_info()->addr_limit);
-		current_thread_info()->addr_limit = ((mm_segment_t) { (-1UL) });
+		oldfs = force_uaccess_begin();
 #endif
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0))
 		err = sock_sendmsg(sock, &msg);
@@ -4152,8 +4149,7 @@ done:
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 		set_fs(oldfs);
 #else
-		current_thread_info()->addr_limit = (oldfs);
-
+		force_uaccess_end(oldfs)
 #endif
 
 		if (err > 0)

+ 8 - 10
os_dep/osdep_service.c

@@ -28,7 +28,9 @@ atomic_t _malloc_size = ATOMIC_INIT(0);
 #endif /* DBG_MEMORY_LEAK */
 
 
+
 #if defined(PLATFORM_LINUX)
+
 /*
 * Translate the OS dependent @param error_code to OS independent RTW_STATUS_CODE
 * @return: one of RTW_STATUS_CODE
@@ -2204,8 +2206,7 @@ static int isFileReadable(const char *path, u32 *sz)
 		oldfs = get_fs();
 		set_fs(KERNEL_DS);
 	#else
-		oldfs = (current_thread_info()->addr_limit);
-		current_thread_info()->addr_limit = ((mm_segment_t) { (-1UL) });
+		oldfs = force_uaccess_begin();;
 	#endif
 
 		if (1 != readFile(fp, &buf, 1))
@@ -2222,8 +2223,7 @@ static int isFileReadable(const char *path, u32 *sz)
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 		set_fs(oldfs);
 #else
-		current_thread_info()->addr_limit = (oldfs);
-
+        force_uaccess_end(oldfs);
 #endif
 		filp_close(fp, NULL);
 	}
@@ -2252,14 +2252,13 @@ static int retriveFromFile(const char *path, u8 *buf, u32 sz)
 			oldfs = get_fs();
 			set_fs(KERNEL_DS);
 		#else
-			oldfs = (current_thread_info()->addr_limit);
-				current_thread_info()->addr_limit = ((mm_segment_t) { (-1UL) });
+			oldfs = force_uaccess_begin();
 		#endif
 			ret = readFile(fp, buf, sz);
 		#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 			set_fs(oldfs);
 		#else
-			current_thread_info()->addr_limit = (oldfs);
+      		force_uaccess_end(oldfs);
 		#endif
 			closeFile(fp);
 
@@ -2296,14 +2295,13 @@ static int storeToFile(const char *path, u8 *buf, u32 sz)
 			oldfs = get_fs();
 			set_fs(KERNEL_DS);
 		#else
-			oldfs = (current_thread_info()->addr_limit);
-			current_thread_info()->addr_limit = ((mm_segment_t) { (-1UL) });
+	   		oldfs = force_uaccess_begin();
 		#endif
 			ret = writeFile(fp, buf, sz);
 		#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 			set_fs(oldfs);
 		#else
-			current_thread_info()->addr_limit = (oldfs);
+			force_uaccess_end(oldfs);
 		#endif
 			closeFile(fp);