Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755323Ab2JVPRf (ORCPT ); Mon, 22 Oct 2012 11:17:35 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:46942 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755203Ab2JVPR2 (ORCPT ); Mon, 22 Oct 2012 11:17:28 -0400 MIME-Version: 1.0 In-Reply-To: <1350897568-14262-1-git-send-email-ffainelli@freebox.fr> References: <1350647942-5260-1-git-send-email-ffainelli@freebox.fr> <1350897568-14262-1-git-send-email-ffainelli@freebox.fr> Date: Mon, 22 Oct 2012 08:17:27 -0700 X-Google-Sender-Auth: _WLcM4VkjLbRBQ7euROSOaNHnaw Message-ID: Subject: Re: [PATCH v2] pstore/ram: fix undefined usage of rounddown_pow_of_two(0) From: Kees Cook To: Florian Fainelli Cc: cbouatmailru@gmail.com, ccross@android.com, tony.luck@intel.com, linux-kernel@vger.kernel.org, Maxime Bizon , stable@vger.kernel.org Content-Type: text/plain; charset=ISO-8859-1 X-System-Of-Record: true Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 981 Lines: 27 On Mon, Oct 22, 2012 at 2:19 AM, Florian Fainelli wrote: > From: Maxime Bizon > > record_size / console_size / ftrace_size can be 0 (this is how you > disable the feature), but rounddown_pow_of_two(0) is undefined. As suggested > by Kees Cook, use !is_power_of_2() as a condition to call rounddown_pow_of_two > and avoid its undefined behavior on the value 0. This issue has been present > since commit 1894a253 (ramoops: Move to fs/pstore/ram.c). > > CC: stable@vger.kernel.org > Signed-off-by: Maxime Bizon > Signed-off-by: Florian Fainelli Thanks for the fix! Acked-by: Kees Cook -Kees -- Kees Cook Chrome OS Security -- 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/