Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1575826
| From | Mark Rutland <mark.rutland@arm.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [kernel-hardening] Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION |
| Date | 2017-02-07 17:10 +0100 |
| Message-ID | <t8gv8-56A-1@gated-at.bofh.it> (permalink) |
| References | (5 earlier) <t89tE-rN-27@gated-at.bofh.it> <t8bYt-27Z-3@gated-at.bofh.it> <t8ddT-2Qi-3@gated-at.bofh.it> <t8etj-3Av-5@gated-at.bofh.it> <t8fz4-4vL-17@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Tue, Feb 07, 2017 at 04:07:37PM +0100, Peter Zijlstra wrote:
> On Tue, Feb 07, 2017 at 01:50:20PM +0000, Mark Rutland wrote:
> > > Right something along those lines. (a) will need GCC help, and (b) would
> > > be kernel-arch specific. So this isn't something we can quickly do.
> >
> > I agree this isn't something that can be hacked together quickly, and
> > certainly shouldn't block these patches.
> >
> > However, I don't think we need anything new from GCC, and I think we
> > already have a generic API for (b).
> >
> > For (a) we don't need new GCC help if we do something like we did in
> > commit 72c5839515260dce to do the mangling. Prepend a prefix to the
> > register, e.g. changing 'x0' to '__pt_regs_offset_x0', which we arrange
> > to hold the correct value.
>
> I'm not sure I can decipher that commit and therefore have no idea if
> something similar can be done for other architectures.
For x86 it's a little painful due to '%' in the register names, but it looks
possible. The below appears to do the mangling correctly (then screams due to
the mangled result being nonexistent).
Thanks,
Mark.
---->8----
#define cmpxchg(ptr, old, new) \
({ \
typeof(*ptr) __ret; \
typeof(*ptr) __old = (old); \
typeof(*ptr) __new = (new); \
\
volatile unsigned int *__ptr = (volatile unsigned int *)ptr; \
asm volatile("cmpxchgl %2, %1" \
: "=a" (__ret), "+m" (*__ptr) \
: "r" (__new), "0" (__old) \
: "memory"); \
__ret; \
})
asm(
" .macro reg_to_offset r\n"
" .irp rs,eax,ebx,ecx,edx\n"
" .ifc \\r, %\\rs\n"
" __offset_of_\\rs\n"
" .endif\n"
" .endr\n"
" .endm\n"
);
#define asm_sym(var) asm volatile("reg_to_offset %0\n" : : "r" (var))
int foo(void)
{
unsigned int mem = 0;
unsigned int new;
int bar = 7, baz = 11;
new = cmpxchg(&mem, 1, 2);
asm_sym(new);
}
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/4] refcount_t followups... Kees Cook <keescook@chromium.org> - 2017-02-04 00:30 +0100
[PATCH 2/4] lkdtm: convert to refcount_t testing Kees Cook <keescook@chromium.org> - 2017-02-04 00:30 +0100
[tip:locking/core] lkdtm: Convert to refcount_t testing tip-bot for Kees Cook <tipbot@zytor.com> - 2017-02-10 09:50 +0100
[PATCH 3/4] bug: Switch data corruption check to __must_check Kees Cook <keescook@chromium.org> - 2017-02-04 00:30 +0100
[PATCH 1/4] refcount_t: fix Kconfig help Kees Cook <keescook@chromium.org> - 2017-02-04 00:30 +0100
[PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Kees Cook <keescook@chromium.org> - 2017-02-04 00:30 +0100
Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Peter Zijlstra <peterz@infradead.org> - 2017-02-05 16:50 +0100
Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Kees Cook <keescook@chromium.org> - 2017-02-06 00:40 +0100
Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Peter Zijlstra <peterz@infradead.org> - 2017-02-06 10:00 +0100
Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Kees Cook <keescook@chromium.org> - 2017-02-06 18:00 +0100
Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Peter Zijlstra <peterz@infradead.org> - 2017-02-07 09:40 +0100
Re: [kernel-hardening] Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Mark Rutland <mark.rutland@arm.com> - 2017-02-07 12:20 +0100
Re: [kernel-hardening] Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Peter Zijlstra <peterz@infradead.org> - 2017-02-07 13:40 +0100
Re: [kernel-hardening] Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Mark Rutland <mark.rutland@arm.com> - 2017-02-07 15:00 +0100
Re: [kernel-hardening] Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Peter Zijlstra <peterz@infradead.org> - 2017-02-07 16:10 +0100
Re: [kernel-hardening] Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Mark Rutland <mark.rutland@arm.com> - 2017-02-07 17:10 +0100
Re: [kernel-hardening] Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Peter Zijlstra <peterz@infradead.org> - 2017-02-07 18:40 +0100
Re: [kernel-hardening] Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Mark Rutland <mark.rutland@arm.com> - 2017-02-07 19:00 +0100
Re: [kernel-hardening] Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Peter Zijlstra <peterz@infradead.org> - 2017-02-08 10:20 +0100
Re: [kernel-hardening] Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Peter Zijlstra <peterz@infradead.org> - 2017-02-08 10:50 +0100
Re: [kernel-hardening] Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Mark Rutland <mark.rutland@arm.com> - 2017-02-08 16:00 +0100
Re: [kernel-hardening] Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Kees Cook <keescook@chromium.org> - 2017-02-08 22:30 +0100
Re: [kernel-hardening] Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Peter Zijlstra <peterz@infradead.org> - 2017-02-09 11:30 +0100
Re: [kernel-hardening] Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Kees Cook <keescook@chromium.org> - 2017-02-11 00:40 +0100
csiph-web