On Mon, Jan 27, 2014 at 7:35 PM, Ren Qiaowei <qiaowei.ren@xxxxxxxxx> wrote:I don't mean the same instruction that just trapped.On 01/28/2014 04:36 AM, Andy Lutomirski wrote:If allocation of the bound table fail, the related entry in the bound
+ bd_entry = status & MPX_BNDSTA_ADDR_MASK;
+ if ((bd_entry >= bd_base) && (bd_entry < bd_base + bd_size))
+ allocate_bt(bd_entry);
What happens if this fails? Retrying forever isn't very nice.
directory is still invalid. The following access to this entry still produce
#BR fault.
By the "following access" I think you mean the same instruction that
just trapped -- it will trap again because the exception hasn't been
fixed up. Then mmap will fail again, and you'll retry again, leading
to an infinite loop.
I think that failure to fix up the exception should either let theMaybe we need HPA help answer this question. Peter, what do you think about it? If allocation of the bound table fail, what should we do?
normal bounds error through or should raise SIGBUS.
do_trap() -> do_trap_no_signal() call similar code to check if the fault occurred in userspace or kernel space. You can see previous discussion for the first version of this patchset.
It checks whether #BR come from user-space. You can see do_trap_no_signal().+ if (!user_mode(regs)) {
+ if (!fixup_exception(regs)) {
+ tsk->thread.error_code = error_code;
+ tsk->thread.trap_nr = X86_TRAP_BR;
+ die("bounds", regs, error_code);
+ }
Why the fixup? Unless I'm missing something, the kernel has no business
getting #BR on access to a user address.
Or are you adding code to allow the kernel to use MPX itself? If so,
shouldn't this use an MPX-specific fixup to allow normal C code to use
this stuff?
Wasn't #BR using do_trap before? do_trap doesn't call
fixup_exception. I don't see why it should do it now. (I also don't
think it should come from kernel space until someone adds kernel-mode
MPX support.)