From patchwork Tue Aug 16 21:11:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9284735 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AC8BC607FD for ; Tue, 16 Aug 2016 21:11:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BC4E28538 for ; Tue, 16 Aug 2016 21:11:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FCB828703; Tue, 16 Aug 2016 21:11:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id C0C4428538 for ; Tue, 16 Aug 2016 21:11:55 +0000 (UTC) Received: (qmail 8044 invoked by uid 550); 16 Aug 2016 21:11:35 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: kernel-hardening@lists.openwall.com Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 7768 invoked from network); 16 Aug 2016 21:11:31 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SXYMmxy8fucR6nE1VXUQaBqyhHElJVDFtSSB/9nqRCg=; b=FmkKAsQRIi1ypOrNpt19BTUsLS43K6bfbRk730BUa4zlbmw9B9JjDIjCuIiJtSwlwt 3fs9fbA3QZJHnOoG9eBvE95o3j78B774RVWGqj1wxy8xW5ILi8B0n5jH+W94ao2Q2WDs apoKZ0f25rQCgf5EbIkbU8OVvQYs1XHOlPNks= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SXYMmxy8fucR6nE1VXUQaBqyhHElJVDFtSSB/9nqRCg=; b=ctGKcrngrwTxG2uZLzjrJ0qRsld/tqQq7mLzFFHkynkSeQjX4PmqQPX27ixizAH56Y kxf55clyamkb5UWQoAkPwOYbjHkhet3bsVqK+kyPg25R6N0bJQYcxNahMFO5fn1Z/5JL hhLNpgMRmwV/uHQ7PwBoWohJVXylLlMrNHsc3QR+m/jGKz0zDnb+o2SYnMd+xHVCvjYa mo1E6cbv2vWPyXQOEwtyMAHf54HlSreCQH7Ko9zZqNcyUour9bVqDYU+BwJq2dHYp8Jy ys4krC3XgC8g+888230SYt1LrjSH9D/X5dhgWjdzaT0IfTeAqL2aC8itLloiqXUr+qtT v0xg== X-Gm-Message-State: AEkoousrb05ysebjoJaTIrrxiWeyL82N6zaBcPFK/Al1g7mOx9WPHEG+7qDw9VWW/YaD1urq X-Received: by 10.66.181.16 with SMTP id ds16mr68069312pac.102.1471381879648; Tue, 16 Aug 2016 14:11:19 -0700 (PDT) From: Kees Cook To: "Paul E . McKenney" Cc: Kees Cook , Stephen Boyd , Daniel Micay , Arnd Bergmann , Greg Kroah-Hartman , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Peter Zijlstra , Ingo Molnar , Tejun Heo , Michael Ellerman , "Aneesh Kumar K.V" , "Kirill A. Shutemov" , Andrew Morton , Dan Williams , Jan Kara , Josef Bacik , Thomas Gleixner , Andrey Ryabinin , Nikolay Aleksandrov , Dmitry Vyukov , linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Date: Tue, 16 Aug 2016 14:11:02 -0700 Message-Id: <1471381865-25724-3-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1471381865-25724-1-git-send-email-keescook@chromium.org> References: <1471381865-25724-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [PATCH 2/5] rculist: Consolidate DEBUG_LIST for list_add_rcu() X-Virus-Scanned: ClamAV using ClamSMTP Consolidates the debug checking for list_add_rcu() into the new single debug function. Notably, this fixes the sanity check that was added in commit 17a801f4bfeb ("list_debug: WARN for adding something already in the list"). Before, it wasn't being checked for RCU lists. Signed-off-by: Kees Cook --- include/linux/rculist.h | 8 +++----- lib/list_debug.c | 19 ------------------- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/include/linux/rculist.h b/include/linux/rculist.h index 8beb98dcf14f..b21923e6e9b3 100644 --- a/include/linux/rculist.h +++ b/include/linux/rculist.h @@ -45,19 +45,17 @@ static inline void INIT_LIST_HEAD_RCU(struct list_head *list) * This is only for internal list manipulation where we know * the prev/next entries already! */ -#ifndef CONFIG_DEBUG_LIST static inline void __list_add_rcu(struct list_head *new, struct list_head *prev, struct list_head *next) { + if (!__list_add_debug(new, prev, next)) + return; + new->next = next; new->prev = prev; rcu_assign_pointer(list_next_rcu(prev), new); next->prev = new; } -#else -void __list_add_rcu(struct list_head *new, - struct list_head *prev, struct list_head *next); -#endif /** * list_add_rcu - add a new entry to rcu-protected list diff --git a/lib/list_debug.c b/lib/list_debug.c index 5d78982eeb99..e90a931bd5ab 100644 --- a/lib/list_debug.c +++ b/lib/list_debug.c @@ -80,22 +80,3 @@ void list_del(struct list_head *entry) entry->prev = LIST_POISON2; } EXPORT_SYMBOL(list_del); - -/* - * RCU variants. - */ -void __list_add_rcu(struct list_head *new, - struct list_head *prev, struct list_head *next) -{ - WARN(next->prev != prev, - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n", - prev, next->prev, next); - WARN(prev->next != next, - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n", - next, prev->next, prev); - new->next = next; - new->prev = prev; - rcu_assign_pointer(list_next_rcu(prev), new); - next->prev = new; -} -EXPORT_SYMBOL(__list_add_rcu);