Skip to content

Commit

Permalink
x86: properly initialize temp insn buffer for paravirt patching
Browse files Browse the repository at this point in the history
With commit ab144f5 the patching code
now collects the complete new instruction stream into a temp buffer
before finally patching in the new insns.  In some cases the paravirt
patchers will choose to leave the patch site unpatched (length mismatch,
clobbers mismatch, etc).

This causes the new patching code to copy an uninitialized temp buffer,
i.e.  garbage, to the callsite.  Simply make sure to always initialize
the buffer with the original instruction stream.  A better fix is to
audit all the patchers and return proper length so that apply_paravirt()
can skip copies when we leave the patch site untouched.

Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Chris Wright authored and Linus Torvalds committed Aug 18, 2007
1 parent 18115f4 commit d34fda4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arch/i386/kernel/alternative.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ void apply_paravirt(struct paravirt_patch_site *start,
unsigned int used;

BUG_ON(p->len > MAX_PATCH_LEN);
/* prep the buffer with the original instructions */
memcpy(insnbuf, p->instr, p->len);
used = paravirt_ops.patch(p->instrtype, p->clobbers, insnbuf,
(unsigned long)p->instr, p->len);

Expand Down

0 comments on commit d34fda4

Please sign in to comment.