From patchwork Fri Sep 22 21:29:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 114104 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3757075qgf; Fri, 22 Sep 2017 14:32:06 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDieJmaOwppDyu9Fg73tV9FNvMmCyw8JQImTArMzwzwleIrKx1UO2MH3iHzq1wkSgwfH8rl X-Received: by 10.98.39.71 with SMTP id n68mr384911pfn.323.1506115926278; Fri, 22 Sep 2017 14:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506115926; cv=none; d=google.com; s=arc-20160816; b=qiXsIIA4znP8GMbH9Qekqdg+a0h3MALx1NPp1GmwTLdB1VCNTLU9Mg4jhurBLRxT5g KQODh7kbWhDiGQDDsg1TiURxpYPeCBP9TNbvOOs3+CGUGHCPnLB7CjrGda3+hA17zNkD DElzQlxm5v9rRp0CPvdOALtUdotGFr7JdhZ01xpelCe1c+vtwqoK+bcUrNajI2Zjmu3A uvPQsQUk8BlsDBpwRQ8IH9p7NbJziZqG2IOUsR/nR3on79vWx+MtjO48iT6/WPTprNFE 6KPZnXxVRGOIaJXEt18b+jlB/cAnx7KLeKW6ZnhlP5x8shtM7NmTbUpB37EpygJYLCl4 IAVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=bJNzdXVs4x+I/Spw5bmunWCCZN+Pdd9U5ZpHkEZZLnM=; b=yxVIxOfNG2e4Ug0sIySkMgxLzOHEF+vg2YbJuSRt9VEOZRzvohnazKtA6AfkxY9FbO sBME6FjGvwc+6Wdnbd6iJrF8nS3vjTFEdLQ9qTE2tdV5/IxO6m3PQnppqxIylhktDLmG WEdMr5Ogr881rUtUhcGl2XMYnpGQRGEimreEkdJxWdZXtjpJmWQXejKQgQWzTocpp+T1 CSN9GxF+n8kcOEUdiN9vWoFnglxek0xFauVhh2vPi9ap90/M12Yxy4INNjXn42vb9Oop /wXmLqIRuEQSEgyDXdIC0xHQdOp80cH9kdQYkm72gEx4f7GOt94HugIpChtkwzk3hbht W6gg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y72si398211plh.261.2017.09.22.14.32.06; Fri, 22 Sep 2017 14:32:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752779AbdIVVcF (ORCPT + 8 others); Fri, 22 Sep 2017 17:32:05 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:51623 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752395AbdIVVcB (ORCPT ); Fri, 22 Sep 2017 17:32:01 -0400 Received: from wuerfel.lan ([95.208.190.237]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0M1vXH-1d78072JAZ-00u3Ur; Fri, 22 Sep 2017 23:30:28 +0200 From: Arnd Bergmann To: Mauro Carvalho Chehab Cc: Arnd Bergmann , Jiri Pirko , Arend van Spriel , Kalle Valo , "David S. Miller" , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Masahiro Yamada , Michal Marek , Andrew Morton , Kees Cook , Geert Uytterhoeven , Greg Kroah-Hartman , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, brcm80211-dev-list@cypress.com, kasan-dev@googlegroups.com, linux-kbuild@vger.kernel.org, Jakub Jelinek , =?utf-8?q?Martin_Li=C5=A1ka?= , stable@vger.kernel.org Subject: [PATCH v4 4/9] em28xx: fix em28xx_dvb_init for KASAN Date: Fri, 22 Sep 2017 23:29:15 +0200 Message-Id: <20170922212930.620249-5-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170922212930.620249-1-arnd@arndb.de> References: <20170922212930.620249-1-arnd@arndb.de> X-Provags-ID: V03:K0:2nezABvorRJeJBNv7yRt+Dd7sNnFoCe4QWgaSHL9j3Vmv+cTgC2 rZuXZV1grLk5zTCZcWEH46nFE84NV+z36fy1LqWc/OarSCXZJRGZUppURKuysN2vm95n6gp PxqBqsntcGtCGJKu3aMPbAlKyCFhTBoy2t0QtVNyCjvRTbm57ClL/WE75xCjWC7lG35wFZ4 5L/bKh5724SjIDSvEGV9Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:e77tphaAIks=:W4CKRnb6jEGYjgAEYybIgu 5ajV05fLExbLb4eNOLMNpvyPlhINAIWvDGq5bSZ6ZkhPrxq5man/H5JvnWaBsILWqkTIeteuO S7mbqrrEQeZ7eOmYYPwy362W3suT5D/36joyVbjfSAvqMgfGxuaefupxi0cSyXw+T0blxuTi1 sS9oUhzuuRHdqRlWKfNNAUbFaM/Zzq9nYtqAel/SGKKNsNJC2NVyDgVJJDH96urEeubcLuXuR nL12zIC9jzXSGrgI9DZoj8lrf7yu2L/DVQrFq2/LoeggF6xeXasIl3j54N/r7460XnTM/u5E9 14JFpMnpTEFTtxCSoOS4DzLMVzMoPwXZk1xAJ8+zEJGhdOPeN2F8SKc7qF0/LHT848pNNW1ck JF3VbACZWqBZTBhrMwcN1j/QrcHSmyLjofo59KdXTMfss/TC9d2ZB/Mkhr9y99aJhE6s5XBjv UP2tNICRTyw/9SUuPMjLu6zg2pEPtgbyfsl5Y8cKvmlZE+VLqbQ+OjBhGz7N7H/Ieex4U6xwF duz5wuJtR46/f8PEZbCtKc64NKuUY6ky+sWhesIZ+l7vvM6Y/c9AHW4N4tlyJyFalVn1XH2pv 3BhtVPgaRkQ7a4xBWjTHATAhM0XWNOdrl6YANkgfCm3f4bUC3u3/F8MMA7+dRCyR80gnLU26M H7F3syHyxfVC4vZBJS7EeCRAGh0RmgcMu8iBr83GLWJORtFlpn34IFdU8yfjUAHHuRwgsNjx9 /uWTix1SsFQ6LqmH2oY0jSBvlxNK2rwe8VwoAA== Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org With CONFIG_KASAN, the init function uses a large amount of kernel stack: drivers/media/usb/em28xx/em28xx-dvb.c: In function 'em28xx_dvb_init.part.4': drivers/media/usb/em28xx/em28xx-dvb.c:2061:1: error: the frame size of 3232 bytes is larger than 2048 bytes [-Werror=frame-larger-than=] It seems that this is triggered in part by using strlcpy(), which the compiler doesn't recognize as copying at most 'len' bytes, since strlcpy is not part of the C standard. It does however recognize the standard strncpy() and optimizes away the extra checks for that, using only 1688 bytes in the end. I have another larger patch that we could use in addition to this one, in order to shrink the stack for -fsanitize-address-use-after-scope (with gcc-7.1.1) as well, but that would not be appropriate for stable backports, so let's focus on this one first. Cc: stable@vger.kernel.org Signed-off-by: Arnd Bergmann --- drivers/media/usb/em28xx/em28xx-dvb.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) -- 2.9.0 diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c index 4a7db623fe29..06c363dc55ed 100644 --- a/drivers/media/usb/em28xx/em28xx-dvb.c +++ b/drivers/media/usb/em28xx/em28xx-dvb.c @@ -1440,7 +1440,7 @@ static int em28xx_dvb_init(struct em28xx *dev) tda10071_pdata.pll_multiplier = 20, tda10071_pdata.tuner_i2c_addr = 0x14, memset(&board_info, 0, sizeof(board_info)); - strlcpy(board_info.type, "tda10071_cx24118", I2C_NAME_SIZE); + strncpy(board_info.type, "tda10071_cx24118", I2C_NAME_SIZE - 1); board_info.addr = 0x55; board_info.platform_data = &tda10071_pdata; request_module("tda10071"); @@ -1460,7 +1460,7 @@ static int em28xx_dvb_init(struct em28xx *dev) /* attach SEC */ a8293_pdata.dvb_frontend = dvb->fe[0]; memset(&board_info, 0, sizeof(board_info)); - strlcpy(board_info.type, "a8293", I2C_NAME_SIZE); + strncpy(board_info.type, "a8293", I2C_NAME_SIZE - 1); board_info.addr = 0x08; board_info.platform_data = &a8293_pdata; request_module("a8293"); @@ -1643,7 +1643,7 @@ static int em28xx_dvb_init(struct em28xx *dev) m88ds3103_pdata.ts_clk_pol = 1; m88ds3103_pdata.agc = 0x99; memset(&board_info, 0, sizeof(board_info)); - strlcpy(board_info.type, "m88ds3103", I2C_NAME_SIZE); + strncpy(board_info.type, "m88ds3103", I2C_NAME_SIZE - 1); board_info.addr = 0x68; board_info.platform_data = &m88ds3103_pdata; request_module("m88ds3103"); @@ -1664,7 +1664,7 @@ static int em28xx_dvb_init(struct em28xx *dev) /* attach tuner */ ts2020_config.fe = dvb->fe[0]; memset(&board_info, 0, sizeof(board_info)); - strlcpy(board_info.type, "ts2022", I2C_NAME_SIZE); + strncpy(board_info.type, "ts2022", I2C_NAME_SIZE - 1); board_info.addr = 0x60; board_info.platform_data = &ts2020_config; request_module("ts2020"); @@ -1690,7 +1690,7 @@ static int em28xx_dvb_init(struct em28xx *dev) /* attach SEC */ a8293_pdata.dvb_frontend = dvb->fe[0]; memset(&board_info, 0, sizeof(board_info)); - strlcpy(board_info.type, "a8293", I2C_NAME_SIZE); + strncpy(board_info.type, "a8293", I2C_NAME_SIZE - 1); board_info.addr = 0x08; board_info.platform_data = &a8293_pdata; request_module("a8293"); @@ -1729,7 +1729,7 @@ static int em28xx_dvb_init(struct em28xx *dev) si2168_config.fe = &dvb->fe[0]; si2168_config.ts_mode = SI2168_TS_PARALLEL; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2168", I2C_NAME_SIZE); + strncpy(info.type, "si2168", I2C_NAME_SIZE - 1); info.addr = 0x64; info.platform_data = &si2168_config; request_module(info.type); @@ -1755,7 +1755,7 @@ static int em28xx_dvb_init(struct em28xx *dev) si2157_config.mdev = dev->media_dev; #endif memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2157", I2C_NAME_SIZE); + strncpy(info.type, "si2157", I2C_NAME_SIZE - 1); info.addr = 0x60; info.platform_data = &si2157_config; request_module(info.type); @@ -1793,7 +1793,7 @@ static int em28xx_dvb_init(struct em28xx *dev) si2168_config.fe = &dvb->fe[0]; si2168_config.ts_mode = SI2168_TS_PARALLEL; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2168", I2C_NAME_SIZE); + strncpy(info.type, "si2168", I2C_NAME_SIZE - 1); info.addr = 0x64; info.platform_data = &si2168_config; request_module(info.type); @@ -1819,7 +1819,7 @@ static int em28xx_dvb_init(struct em28xx *dev) si2157_config.mdev = dev->media_dev; #endif memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2146", I2C_NAME_SIZE); + strncpy(info.type, "si2146", I2C_NAME_SIZE - 1); info.addr = 0x60; info.platform_data = &si2157_config; request_module("si2157"); @@ -1853,7 +1853,7 @@ static int em28xx_dvb_init(struct em28xx *dev) /* attach demod */ memset(&tc90522_config, 0, sizeof(tc90522_config)); memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "tc90522sat", I2C_NAME_SIZE); + strncpy(info.type, "tc90522sat", I2C_NAME_SIZE - 1); info.addr = 0x15; info.platform_data = &tc90522_config; request_module("tc90522"); @@ -1875,7 +1875,7 @@ static int em28xx_dvb_init(struct em28xx *dev) qm1d1c0042_config.fe = tc90522_config.fe; qm1d1c0042_config.lpf = 1; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "qm1d1c0042", I2C_NAME_SIZE); + strncpy(info.type, "qm1d1c0042", I2C_NAME_SIZE - 1); info.addr = 0x61; info.platform_data = &qm1d1c0042_config; request_module(info.type); @@ -1913,7 +1913,7 @@ static int em28xx_dvb_init(struct em28xx *dev) si2168_config.fe = &dvb->fe[0]; si2168_config.ts_mode = SI2168_TS_SERIAL; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2168", I2C_NAME_SIZE); + strncpy(info.type, "si2168", I2C_NAME_SIZE - 1); info.addr = 0x64; info.platform_data = &si2168_config; request_module(info.type); @@ -1939,7 +1939,7 @@ static int em28xx_dvb_init(struct em28xx *dev) si2157_config.mdev = dev->media_dev; #endif memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2157", I2C_NAME_SIZE); + strncpy(info.type, "si2157", I2C_NAME_SIZE - 1); info.addr = 0x60; info.platform_data = &si2157_config; request_module(info.type); @@ -1975,7 +1975,7 @@ static int em28xx_dvb_init(struct em28xx *dev) lgdt3306a_config = hauppauge_01595_lgdt3306a_config; lgdt3306a_config.fe = &dvb->fe[0]; lgdt3306a_config.i2c_adapter = &adapter; - strlcpy(info.type, "lgdt3306a", sizeof(info.type)); + strncpy(info.type, "lgdt3306a", sizeof(info.type) - 1); info.addr = 0x59; info.platform_data = &lgdt3306a_config; request_module(info.type); @@ -2002,7 +2002,7 @@ static int em28xx_dvb_init(struct em28xx *dev) si2157_config.mdev = dev->media_dev; #endif memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2157", sizeof(info.type)); + strncpy(info.type, "si2157", sizeof(info.type) - 1); info.addr = 0x60; info.platform_data = &si2157_config; request_module(info.type);