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: 9601343 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 A810860429 for ; Thu, 2 Mar 2017 18:13:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F120285D1 for ; Thu, 2 Mar 2017 18:13:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93AF5285D3; Thu, 2 Mar 2017 18:13:27 +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.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham 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 002FE285D1 for ; Thu, 2 Mar 2017 18:13:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932122AbdCBSNZ (ORCPT ); Thu, 2 Mar 2017 13:13:25 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:62370 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752009AbdCBSNW (ORCPT ); Thu, 2 Mar 2017 13:13:22 -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:H+y8i9AQPmI=:NFP14P6qbyf6kwbzLhdlJD So/GbPFEYxJX2bjvVkuhz34twJ+UYTwpRRTGkgr6bUhEtZmjJUYf2x9MGjjlwalL89sOTc/9L 7frmc0BOsTZoty9W5h4FRIWOBhT0jShuJ54u7EK//v3I/Yg0xN8/Og7ip6haIRAeJ2Sw+3mpI O3w7AFeJNYGjik72bhnAfsd92ghj5v4mQD4zbJA7QTLFs+5Yg7rK5k3erw5Ma5Tx0rYmj5ipN CZLURtZgPce2YIeCYkO4rVE2EfT18EpxS62CwsNnEEDMeJhoKXT3MkzS94Wxp/znu0guD2hCZ vx6i3xcHiHoUtJj7u1AHa+ahVJZ/EIBM7FhSz8PgLI7xux8CjyMw5sSQCFJDrf6cfsisdvlN3 kbf/niKvE0hFFXeyTFidGoUYjHcRbi7FKfMex4vtp0LQy3fsxG2Mm6KSsYKiFyoeOMQUdyQDA 1NIRhfx0482lpBCj5kkzK2Ahv9V+LVGauUU5Ql8ahZzkeQtHCOvtZXQcRD1yFUqBRThJGjEw9 BDUxNqx84DANaYqbJv5M8xhiT0UkZmSWTiJQFNPTkk+GRPlvya3W/g6rKDwce9ZpgRsMzUs37 sCnLrHdDHN1gsYCV7jjsX9dtPG6PRY5Zy6ShOY3cEwNxXLb+Dh+kss7NrNyY9WiuV/bdI9wnv AnPcPWWvJEcxSAfhsSZMqfCi/88xXn2wPAhcYQ0bwuWt8O3hgF6XU/2AodOU+TPmWd4c= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@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;