From patchwork Thu Mar 2 16:38:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9601727 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4F63D60429 for ; Thu, 2 Mar 2017 22:27:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40C38279B3 for ; Thu, 2 Mar 2017 22:27:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3527B28600; Thu, 2 Mar 2017 22:27:58 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB41E279B3 for ; Thu, 2 Mar 2017 22:27:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751128AbdCBW1k (ORCPT ); Thu, 2 Mar 2017 17:27:40 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:65343 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751029AbdCBW1g (ORCPT ); Thu, 2 Mar 2017 17:27:36 -0500 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0LkXZc-1cBWRf3XbY-00aRuz; Thu, 02 Mar 2017 17:38:56 +0100 From: Arnd Bergmann To: kasan-dev@googlegroups.com Cc: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-wireless@vger.kernel.org, kernel-build-reports@lists.linaro.org, "David S . Miller" , Arnd Bergmann Subject: [PATCH 18/26] [media] i2c: cx25840: avoid stack overflow with KASAN Date: Thu, 2 Mar 2017 17:38:26 +0100 Message-Id: <20170302163834.2273519-19-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170302163834.2273519-1-arnd@arndb.de> References: <20170302163834.2273519-1-arnd@arndb.de> X-Provags-ID: V03:K0:B+x1fhx5M+jMWs8xcHPPz4IcSgMpbtY2rMKtwhPHCGBfyOMzeSV ApQ7YXqYZv+wKV1/UGO0N9AoA7ff3nlFVLoLGIv0VHZVg7+C5S+Rw051i5s/WEX5Smq3Afe c+X62TxcUfUZPBdw9flck5gwaRiD2d54fwUIL081fNvzVjiPdURwovjUBuFslorIcM74PCJ bqQyWk+ovaDLystbpMQwA== X-UI-Out-Filterresults: notjunk:1; V01:K0:NbeYs2CJ7HI=:9i7n2nmke6fsPvQm2rdcYv nAQ4Z4bfrcjx+DM1SIjT1gSX1DPyhJsko8/TLgUYjkTLRv4G3n7f/IQXs4N/NCqC+SeVzOvVv bvJhcvEcWuAi8Yot56EGsrUfZj8hYOQ0rkSsmAfEX+UJIby0ecIlmEbIu7iEmJvpgFDsTkvQy Q3Hdy6f5upnNsYLu43KEKLzmF0DJQa7xykjNa2NqJaS/fQ3dB2O5WL/r0OzcDIcFfNGyoyTJ9 9BZse1AS7Wx7QeDmGD5Lh5mySVGRi1EnDOHJfDWNgnCNSysTIz514THmK7gpYIWTSWuwRW7d1 zztbVf3Qresb/vjnOyUkYhmuccfAYKZJkbOb6XDGVMQPDGGtROQSzlA9zlZ2cJbSiAL7NAikh zLGLKvTpCmbgeW1p6i1wVmMlxC7RF/LXX/Y/3HqjY5uPYaTzI87itHaxrW7NTX0Khv4WFG134 02fdNuM6aLWHqObkfzUQRUOvsYyOs6hcLbC2uEpoM8j7X5b1/wXNJdhdmOD9jrI5xeYaOLsAf TgqplYt9g+gXcWPisd1N+19O9d5S0MvoX5l/aLZCfZb4oqIUSONnniWQh7hXNNTTBq+S9UVkL CQqdnJVcsZSZXupFVcqhJuP7/4zpTR0QWO571F0b+fP5zvjagm2niFgJvql9HtcUGXrLN8Yvg g7Y0kEUsHdeMAZQWUVDIOVA5L5friCnYa9X1MYnCD+n6qUnkdOrMsV9QwlQyBwRN2gMM= Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With CONFIG_KASAN, this driver has shown a ridiculously large stack frame in one configuration: drivers/media/i2c/cx25840/cx25840-core.c:4960:1: error: the frame size of 94000 bytes is larger than 2048 bytes [-Werror=frame-larger-than=] In most builds, it's only about 3300 bytes, but that's still large anough to risk a kernel stack overflow. Marking the two register access functions as noinline_for_kasan avoids the problem and brings the largest stack frame size down to 232 bytes. Signed-off-by: Arnd Bergmann --- drivers/media/i2c/cx25840/cx25840-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c index b8d3c070bfc1..fd72e5a11cb9 100644 --- a/drivers/media/i2c/cx25840/cx25840-core.c +++ b/drivers/media/i2c/cx25840/cx25840-core.c @@ -81,7 +81,7 @@ MODULE_PARM_DESC(debug, "Debugging messages [0=Off (default) 1=On]"); /* ----------------------------------------------------------------------- */ static void cx23888_std_setup(struct i2c_client *client); -int cx25840_write(struct i2c_client *client, u16 addr, u8 value) +noinline_for_kasan int cx25840_write(struct i2c_client *client, u16 addr, u8 value) { u8 buffer[3]; buffer[0] = addr >> 8; @@ -90,7 +90,7 @@ int cx25840_write(struct i2c_client *client, u16 addr, u8 value) return i2c_master_send(client, buffer, 3); } -int cx25840_write4(struct i2c_client *client, u16 addr, u32 value) +noinline_for_kasan int cx25840_write4(struct i2c_client *client, u16 addr, u32 value) { u8 buffer[6]; buffer[0] = addr >> 8;