From patchwork Tue Jul 16 04:07:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 11045225 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 678AD6C5 for ; Tue, 16 Jul 2019 04:08:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57F8E28553 for ; Tue, 16 Jul 2019 04:08:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A3FC28573; Tue, 16 Jul 2019 04:08:11 +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=-5.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 7D54F28553 for ; Tue, 16 Jul 2019 04:08:10 +0000 (UTC) Received: (qmail 24169 invoked by uid 550); 16 Jul 2019 04:08:09 -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: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 24148 invoked from network); 16 Jul 2019 04:08:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rmC6wxi5sfJ1hgZ1T5d4GnYkV6yYjgLN1LSLJD9G/N4=; b=Kq0teeTexfzjIuo8X5x7eq1y/4O5B2Bmjf3Fma8qxHKz570TnWd5F41ARTOX+ZB9o5 ZrA8d8qX6imHshG3/BIhlS9G3/USuQssQxWSRVgYqXyJ69AtXg6PA4i/A/poj8yG+f0m jjDlhK3uHe61XmDCNPq7CEmNnt62VWeTQWFEQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rmC6wxi5sfJ1hgZ1T5d4GnYkV6yYjgLN1LSLJD9G/N4=; b=stlfl/G2tH3daIUZkeVvhKcqxSga75WwvR+igWg55fmw9RfnetE11awC/oxe8SXBT2 pJ5R09OcvJiix448qpFFmc4UlVhlfqrbF9FE5wjnwJa2tRP7FerafujHDY06qaACVRRT NbEJdI73XBJ9Uo+RaFMG6XGSacf3Aa2jUH3j41F4S9kR/zQPQ/tO+Sc12/smrOhGNrih PBgVPEcf/C0wKE6TB3Tq+gjD24LsO2drLQziXWrhFN+aIUH6iAX6fvBLuRGUD1l48JkJ RkZJBG7Ch01cJ+970fWNUAyFfW2d7h+8+7nQP/+cvxuUEzxmfxo5txvl7HRbPY8RG7/g hbkg== X-Gm-Message-State: APjAAAUd4o9JnfOOg8QEH4GjqOgEkdQc7XOSR1kcBbvYCfY84hdzlGur E7Z0X+Lo+LlDJ4Gbnb18VAw= X-Google-Smtp-Source: APXvYqzgpmFKYjtDybWIlQwIoYF/PfoRh5ad2Zk33yjjz2GZk9FWUyWvHOfYTa/TTjzB9GZPuRionw== X-Received: by 2002:a63:9249:: with SMTP id s9mr29860119pgn.356.1563250076442; Mon, 15 Jul 2019 21:07:56 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , Paul McKenney , Alexey Kuznetsov , Bjorn Helgaas , Borislav Petkov , c0d1n61at3@gmail.com, "David S. Miller" , edumazet@google.com, Greg Kroah-Hartman , Hideaki YOSHIFUJI , "H. Peter Anvin" , Ingo Molnar , Jonathan Corbet , Josh Triplett , keescook@chromium.org, kernel-hardening@lists.openwall.com, kernel-team@android.com, Lai Jiangshan , Len Brown , linux-acpi@vger.kernel.org, linux-doc@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Mathieu Desnoyers , neilb@suse.com, netdev@vger.kernel.org, Oleg Nesterov , "Paul E. McKenney" , Pavel Machek , peterz@infradead.org, "Rafael J. Wysocki" , Rasmus Villemoes , rcu@vger.kernel.org, Steven Rostedt , Tejun Heo , Thomas Gleixner , will@kernel.org, x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)) Subject: [PATCH] rculist: Add build check for single optional list argument Date: Tue, 16 Jul 2019 00:07:43 -0400 Message-Id: <20190716040743.78343-1-joel@joelfernandes.org> X-Mailer: git-send-email 2.22.0.510.g264f2c817a-goog MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP In a previous patch series [1], we added an optional lockdep expression argument to list_for_each_entry_rcu() and the hlist equivalent. This also meant more than one optional argument can be passed to them with that error going unnoticed. To fix this, let us force a compiler error more than one optional argument is passed. [1] https://lore.kernel.org/patchwork/project/lkml/list/?series=402150 Suggested-by: Paul McKenney Signed-off-by: Joel Fernandes (Google) --- include/linux/rculist.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/linux/rculist.h b/include/linux/rculist.h index 1048160625bb..86659f6d72dc 100644 --- a/include/linux/rculist.h +++ b/include/linux/rculist.h @@ -44,14 +44,18 @@ static inline void INIT_LIST_HEAD_RCU(struct list_head *list) * Check during list traversal that we are within an RCU reader */ +#define check_arg_count_one(dummy) + #ifdef CONFIG_PROVE_RCU_LIST -#define __list_check_rcu(dummy, cond, ...) \ +#define __list_check_rcu(dummy, cond, extra...) \ ({ \ + check_arg_count_one(extra); \ RCU_LOCKDEP_WARN(!cond && !rcu_read_lock_any_held(), \ "RCU-list traversed in non-reader section!"); \ }) #else -#define __list_check_rcu(dummy, cond, ...) ({}) +#define __list_check_rcu(dummy, cond, extra...) \ + ({ check_arg_count_one(extra); }) #endif /*