Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755201AbbDUOHu (ORCPT ); Tue, 21 Apr 2015 10:07:50 -0400 Received: from mx3-phx2.redhat.com ([209.132.183.24]:50418 "EHLO mx3-phx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753512AbbDUOHr (ORCPT ); Tue, 21 Apr 2015 10:07:47 -0400 Date: Tue, 21 Apr 2015 10:07:00 -0400 (EDT) From: Ulrich Obergfell To: Chris Metcalf Cc: Frederic Weisbecker , Don Zickus , Ingo Molnar , Andrew Morton , Andrew Jones , chai wen , Fabian Frederick , Aaron Tomlin , Ben Zhang , Christoph Lameter , Gilad Ben-Yossef , Steven Rostedt , linux-kernel@vger.kernel.org, Jonathan Corbet , linux-doc@vger.kernel.org, Thomas Gleixner , Peter Zijlstra Message-ID: <1642563828.4126628.1429625220545.JavaMail.zimbra@redhat.com> In-Reply-To: <1429295838-6328-2-git-send-email-cmetcalf@ezchip.com> References: <20150416152808.GA16270@lerouge> <1429295838-6328-1-git-send-email-cmetcalf@ezchip.com> <1429295838-6328-2-git-send-email-cmetcalf@ezchip.com> Subject: Re: [PATCH v9 2/3] watchdog: add watchdog_cpumask sysctl to assist nohz MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.36.5.48] X-Mailer: Zimbra 8.0.6_GA_5922 (ZimbraWebClient - FF22 (Linux)/8.0.6_GA_5922) Thread-Topic: watchdog: add watchdog_cpumask sysctl to assist nohz Thread-Index: D4ii++nIFDcoretzWddFUSJUgpTcDQ== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1736 Lines: 50 Chris, I think it would also be nice to check the plausibility of the user input. +int proc_watchdog_cpumask(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + int err; + + mutex_lock(&watchdog_proc_mutex); + err = proc_do_large_bitmap(table, write, buffer, lenp, ppos); + if (!err && write) { + /* Remove impossible cpus to keep sysctl output cleaner. */ + cpumask_and(watchdog_cpumask, watchdog_cpumask, + cpu_possible_mask); + + if (watchdog_enabled && watchdog_thresh) + smpboot_update_cpumask_percpu_thread(&watchdog_threads, + watchdog_cpumask); + } + mutex_unlock(&watchdog_proc_mutex); + return err; +} I think the user should only be allowed to specify a mask that is a subset of tick_nohz_full_mask as only those CPUs don't have a watchdog thread by default. In other words, the user should not be able to interfere with housekeeping CPUs. For example, add a plausibility check like so: save watchdog_cpumask because proc_do_large_bitmap() is going to change it proc_do_large_bitmap() // return an error if the user-specified mask includes a housekeeping CPU if (watchdog_cpumask and 'negated tick_nohz_full_mask') { restore saved watchdog_cpumask return -EINVAL } Regards, Uli -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/