From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756637AbbDVLDa (ORCPT ); Wed, 22 Apr 2015 07:03:30 -0400 Received: from mx6-phx2.redhat.com ([209.132.183.39]:60184 "EHLO mx6-phx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756345AbbDVLD2 (ORCPT ); Wed, 22 Apr 2015 07:03:28 -0400 Date: Wed, 22 Apr 2015 07:02:31 -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: <741962750.4712066.1429700551405.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.3.224.7] 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: EePFelj3AYbW7KoZss3zwnVqa5+7dw== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Chris, in https://lkml.org/lkml/2015/4/17/616 you stated: ">> + alloc_cpumask_var(&watchdog_cpumask_for_smpboot, GFP_KERNEL); > > alloc_cpumask_var could fail? Good catch; if I get a failure I'll just return early without trying to start the watchdog, since clearly things are too memory-constrained to enable that functionality anyway." Let's assume that (in spite of the memory constraints) the kernel would still be able to make progress and get to a point where the system will be usable. In this corner case, the following code would leave a NULL pointer behind in watchdog_cpumask and in watchdog_cpumask_bits which could subsequently lead to a crash. void __init lockup_detector_init(void) { set_sample_period(); + if (!alloc_cpumask_var(&watchdog_cpumask, GFP_KERNEL)) { + pr_err("Failed to allocate cpumask for watchdog"); + return; + } + watchdog_cpumask_bits = cpumask_bits(watchdog_cpumask); For example, proc_watchdog_cpumask() and the change that your patch introduces in watchdog_enable_all_cpus() are not protected against a possible NULL pointer. I think the code needs to be made safer. Regards, Uli