lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150403170625.GJ3418@pd.tnic>
Date:	Fri, 3 Apr 2015 19:06:25 +0200
From:	Borislav Petkov <bp@...en8.de>
To:	Quentin Casasnovas <quentin.casasnovas@...cle.com>
Cc:	X86 ML <x86@...nel.org>, LKML <linux-kernel@...r.kernel.org>,
	"H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...nel.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Oleg Nesterov <oleg@...hat.com>,
	Andy Lutomirski <luto@...capital.net>
Subject: Re: [PATCH] x86/xsave: Robustify and merge macros

On Fri, Apr 03, 2015 at 05:40:55PM +0200, Quentin Casasnovas wrote:
> So yeah I still think we're not properly padding, if you take my earlier
> example where repl2 = 5 bytes, repl1 = 4 bytes and orin_insn = 3.
> 
> I'll let you re-read my original mail and come back to me to tell me what'd
> I really miss! :)

Dammit, dammit, dammit!

And I thought this aspect was taken care of. I went into the old
branches where I had done this and there I have:

+#define OLDINSTR_2(oldinstr, num1, num2)                               \
+       __OLDINSTR(oldinstr, num1)                                      \
+       ".skip -(((" alt_rlen(num2) ")-(" alt_rlen(num1) ")) > 0) * "   \
+               "((" alt_rlen(num2) ")-(" alt_rlen(num1) ")),0x90\n"    \
+       alt_end_marker ":\n"
+

without the size of the orig_insn factored in into the padding.

And that would work for your example because it would add 1+1 bytes
padding.

Basically, the idea was:

.skip len(repl1) - len(orig), 0x90
.skip len(repl2) - len(repl1), 0x90

BUT!, for some reason I changed it to what's there now and I can't
remember why anymore.

IOW, this should fix your example but I need to think about it on a
clear head first, to try to remember what was the problem with that
original approach:

---
diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
index 524bddce0b76..708838260f7c 100644
--- a/arch/x86/include/asm/alternative-asm.h
+++ b/arch/x86/include/asm/alternative-asm.h
@@ -50,7 +50,7 @@
 	\oldinstr
 141:
 	.skip -(((144f-143f)-(141b-140b)) > 0) * ((144f-143f)-(141b-140b)),0x90
-	.skip -(((145f-144f)-(144f-143f)-(141b-140b)) > 0) * ((145f-144f)-(144f-143f)-(141b-140b)),0x90
+	.skip -(((145f-144f)-(144f-143f)) > 0) * ((145f-144f)-(144f-143f)),0x90
 142:
 
 	.pushsection .altinstructions,"a"
diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
index 5aef6a97d80e..2b8cc1dd7dbf 100644
--- a/arch/x86/include/asm/alternative.h
+++ b/arch/x86/include/asm/alternative.h
@@ -101,8 +101,8 @@ static inline int alternatives_text_reserved(void *start, void *end)
  */
 #define OLDINSTR_2(oldinstr, num1, num2)					\
 	__OLDINSTR(oldinstr, num1)						\
-	".skip -(((" alt_rlen(num2) ")-(" alt_rlen(num1) ")-(662b-661b)) > 0) * " \
-		"((" alt_rlen(num2) ")-(" alt_rlen(num1) ")-(662b-661b)),0x90\n"  \
+	".skip -(((" alt_rlen(num2) ")-(" alt_rlen(num1) ")) > 0) * " \
+		"((" alt_rlen(num2) ")-(" alt_rlen(num1) ")),0x90\n"  \
 	alt_end_marker ":\n"
 
 #define ALTINSTR_ENTRY(feature, num)					      \
---

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ