From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C09DC6778C for ; Tue, 3 Jul 2018 14:26:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1662A23D49 for ; Tue, 3 Jul 2018 14:26:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1662A23D49 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753547AbeGCO00 (ORCPT ); Tue, 3 Jul 2018 10:26:26 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:50042 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753129AbeGCO0Z (ORCPT ); Tue, 3 Jul 2018 10:26:25 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 25BEA7A9; Tue, 3 Jul 2018 07:26:25 -0700 (PDT) Received: from [10.1.206.75] (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 15A073F5AD; Tue, 3 Jul 2018 07:26:23 -0700 (PDT) Subject: Re: [PATCH] mmc: core: Fix struct mmc_gpio corruption To: Fabio Estevam Cc: Ulf Hansson , Linus Walleij , Shawn Lin , linux-mmc , linux-kernel References: <20180703141114.11609-1-marc.zyngier@arm.com> From: Marc Zyngier Organization: ARM Ltd Message-ID: <18d70b54-15c9-fff4-6dc3-f2cffb08f836@arm.com> Date: Tue, 3 Jul 2018 15:26:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/07/18 15:14, Fabio Estevam wrote: > Hi Marc, > > On Tue, Jul 3, 2018 at 11:11 AM, Marc Zyngier wrote: >> I recently realised that something was amiss with /proc/interrupts >> on my cubietruck: >> >> 51: 0 0 GICv2 41 Level mv64xxx_i2c >> 59: 1047 0 GICv2 117 Level eth0 >> 66: 2 0 sunxi_pio_edge 1 Edge XXXXX >> >> where XXXXX has some non-ASCII characters, while I was expecting: >> >> 66: 0 0 sunxi_pio_edge 1 Edge 1c0f000.mmc cd >> >> It turns out that the cd_debounce_delay_ms field was recently to >> struct mmc_gpio, and carefully placed at the one spot where it could >> cause damage: right *after* the zero-sized array that contains the >> associated label. This label ends up being passed to the IRQ >> subsystem, and then overwritten by the cd_debounce_delay_ms field. >> >> Funky! >> >> Let's move that field to a less crowded location. >> >> Fixes: bfd694d5e21c ("mmc: core: Add tunable delay before detecting card after card is inserted") >> Cc: Shawn Lin >> Cc: Linus Walleij >> Cc: Ulf Hansson >> Signed-off-by: Marc Zyngier >> --- >> drivers/mmc/core/slot-gpio.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c >> index ef05e0039378..1ccf9dc07395 100644 >> --- a/drivers/mmc/core/slot-gpio.c >> +++ b/drivers/mmc/core/slot-gpio.c >> @@ -27,8 +27,8 @@ struct mmc_gpio { >> bool override_cd_active_level; >> irqreturn_t (*cd_gpio_isr)(int irq, void *dev_id); >> char *ro_label; >> - char cd_label[0]; >> u32 cd_debounce_delay_ms; >> + char cd_label[0]; > > Ulf has already applied a fix for this: > https://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git/commit/?h=fixes&id=60feca8f59a0bbdee9545ab52775cad0171151ff > > which is more robust as it will give a gcc error when cd_label gets > moved in the future. Ah, good. Thanks for the heads-up. M. -- Jazz is not dead. It just smells funny...