From 737afda6fdb357a8fbbf0a7172c06ab3a597bba6 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Mon, 10 May 2021 08:34:16 -0400 Subject: [PATCH] Cleanup: disable page fault after access_ok The page faults don't need to be disabled for access_ok. Simplify the fill buffer error paths. Signed-off-by: Mathieu Desnoyers Change-Id: I2e31d308d45efdfede04e2159c37c066749871ae --- include/ringbuffer/backend.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/ringbuffer/backend.h b/include/ringbuffer/backend.h index 1ede713c..be72d769 100644 --- a/include/ringbuffer/backend.h +++ b/include/ringbuffer/backend.h @@ -286,17 +286,17 @@ void lib_ring_buffer_copy_from_user_inatomic(const struct lttng_kernel_ring_buff index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT; pagecpy = min_t(size_t, len, (-offset) & ~PAGE_MASK); - pagefault_disable(); if (unlikely(!lttng_access_ok(VERIFY_READ, src, len))) goto fill_buffer; + pagefault_disable(); if (likely(pagecpy == len)) { ret = lib_ring_buffer_do_copy_from_user_inatomic( backend_pages->p[index].virt + (offset & ~PAGE_MASK), src, len); if (unlikely(ret > 0)) { /* Copy failed. */ - goto fill_buffer; + goto fill_buffer_enable_pf; } } else { _lib_ring_buffer_copy_from_user_inatomic(bufb, offset, src, len, 0); @@ -306,8 +306,9 @@ void lib_ring_buffer_copy_from_user_inatomic(const struct lttng_kernel_ring_buff return; -fill_buffer: +fill_buffer_enable_pf: pagefault_enable(); +fill_buffer: /* * In the error path we call the slow path version to avoid * the pollution of static inline code. @@ -353,10 +354,10 @@ void lib_ring_buffer_strcpy_from_user_inatomic(const struct lttng_kernel_ring_bu index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT; pagecpy = min_t(size_t, len, (-offset) & ~PAGE_MASK); - pagefault_disable(); if (unlikely(!lttng_access_ok(VERIFY_READ, src, len))) goto fill_buffer; + pagefault_disable(); if (likely(pagecpy == len)) { size_t count; @@ -388,7 +389,6 @@ void lib_ring_buffer_strcpy_from_user_inatomic(const struct lttng_kernel_ring_bu return; fill_buffer: - pagefault_enable(); /* * In the error path we call the slow path version to avoid * the pollution of static inline code. -- 2.34.1