From: Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
Date: Fri, 16 May 97 10:23:58 +0200
To: linux-m68k@phil.uni-sb.de
Subject: L68K: cacheflush, flush_tlb
X-Yow: I'm in direct contact with many advanced fun CONCEPTS.
Sender: owner-linux-m68k@phil.uni-sb.de
Reply-To: linux-m68k@phil.uni-sb.de

Hi!

The first of the two patches fixes some problems in sys_cacheflush that
makes it vulnerable to DOS attack.  The second patch makes flush_tlb
better on the 680[23]0 where we can selectively flush user entries as
well.

Andreas.

----------------------------------------------------------------------
--- arch/m68k/kernel/sys_m68k.c.~1~	Mon Mar 24 17:38:12 1997
+++ arch/m68k/kernel/sys_m68k.c	Sun May 11 02:12:38 1997
@@ -532,12 +532,15 @@
 		 */
 		vma = find_vma (current->mm, addr);
 		ret = -EINVAL;
+		/* Check for overflow.  */
+		if (addr + len < addr)
+			goto out;
 		if (vma == NULL || addr < vma->vm_start || addr + len > vma->vm_end)
 			goto out;
 	}
 
 	if (CPU_IS_020_OR_030) {
-		if (scope == FLUSH_SCOPE_LINE) {
+		if (scope == FLUSH_SCOPE_LINE && len < 256) {
 			unsigned long cacr;
 			__asm__ ("movec %%cacr, %0" : "=r" (cacr));
 			if (cache & FLUSH_CACHE_INSN)
--- include/asm-m68k/pgtable.h.~2~	Tue Feb 18 00:05:20 1997
+++ include/asm-m68k/pgtable.h	Thu May 15 11:20:31 1997
@@ -175,7 +175,7 @@
 }
 
 /*
- * flush all atc entries (user-space entries only for the 680[46]0).
+ * flush all user-space atc entries.
  */
 static inline void __flush_tlb(void)
 {
@@ -184,7 +184,7 @@
 				     "pflushan\n\t"
 				     ".chip 68k");
 	else
-		__asm__ __volatile__("pflusha");
+		__asm__ __volatile__("pflush #0,#4");
 }
 
 static inline void __flush_tlb_one(unsigned long addr)
