{"id":817716,"url":"http://patchwork.ozlabs.org/api/patches/817716/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170922212930.620249-5-arnd@arndb.de/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170922212930.620249-5-arnd@arndb.de>","list_archive_url":null,"date":"2017-09-22T21:29:15","name":"[v4,4/9] em28xx: fix em28xx_dvb_init for KASAN","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":true,"hash":"dd657d58a4158c5ddc00e6e2646c7f7c4dd7cfa8","submitter":{"id":30,"url":"http://patchwork.ozlabs.org/api/people/30/?format=json","name":"Arnd Bergmann","email":"arnd@arndb.de"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170922212930.620249-5-arnd@arndb.de/mbox/","series":[{"id":4712,"url":"http://patchwork.ozlabs.org/api/series/4712/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=4712","date":"2017-09-22T21:29:16","name":"bring back stack frame warning with KASAN","version":4,"mbox":"http://patchwork.ozlabs.org/series/4712/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/817716/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/817716/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xzRX413PTz9s9Y\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 23 Sep 2017 07:32:20 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752758AbdIVVcE (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tFri, 22 Sep 2017 17:32:04 -0400","from mout.kundenserver.de ([212.227.126.187]:51623 \"EHLO\n\tmout.kundenserver.de\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1752395AbdIVVcB (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Fri, 22 Sep 2017 17:32:01 -0400","from wuerfel.lan ([95.208.190.237]) by mrelayeu.kundenserver.de\n\t(mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id\n\t0M1vXH-1d78072JAZ-00u3Ur; Fri, 22 Sep 2017 23:30:28 +0200"],"From":"Arnd Bergmann <arnd@arndb.de>","To":"Mauro Carvalho Chehab <mchehab@kernel.org>","Cc":"Arnd Bergmann <arnd@arndb.de>, Jiri Pirko <jiri@resnulli.us>, Arend van\n\tSpriel <arend.vanspriel@broadcom.com>, \n\tKalle Valo <kvalo@codeaurora.org>, \"David S. Miller\"\n\t<davem@davemloft.net>, Andrey Ryabinin <aryabinin@virtuozzo.com>,\n\tAlexander Potapenko <glider@google.com>, \n\tDmitry Vyukov <dvyukov@google.com>, Masahiro Yamada\n\t<yamada.masahiro@socionext.com>, Michal Marek <mmarek@suse.com>,\n\tAndrew Morton <akpm@linux-foundation.org>, Kees Cook\n\t<keescook@chromium.org>, Geert Uytterhoeven <geert@linux-m68k.org>,\n\tGreg Kroah-Hartman <gregkh@linuxfoundation.org>, \n\tlinux-media@vger.kernel.org, linux-kernel@vger.kernel.org, \n\tnetdev@vger.kernel.org, linux-wireless@vger.kernel.org, \n\tbrcm80211-dev-list.pdl@broadcom.com, brcm80211-dev-list@cypress.com,\n\tkasan-dev@googlegroups.com, linux-kbuild@vger.kernel.org,\n\tJakub Jelinek <jakub@gcc.gnu.org>, =?utf-8?q?Martin_Li=C5=A1ka?=\n\t<marxin@gcc.gnu.org>,         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\n\trZuXZV1grLk5zTCZcWEH46nFE84NV+z36fy1LqWc/OarSCXZJRGZUppURKuysN2vm95n6gp\n\tPxqBqsntcGtCGJKu3aMPbAlKyCFhTBoy2t0QtVNyCjvRTbm57ClL/WE75xCjWC7lG35wFZ4\n\t5L/bKh5724SjIDSvEGV9Q==","X-UI-Out-Filterresults":"notjunk:1; V01:K0:e77tphaAIks=:W4CKRnb6jEGYjgAEYybIgu\n\t5ajV05fLExbLb4eNOLMNpvyPlhINAIWvDGq5bSZ6ZkhPrxq5man/H5JvnWaBsILWqkTIeteuO\n\tS7mbqrrEQeZ7eOmYYPwy362W3suT5D/36joyVbjfSAvqMgfGxuaefupxi0cSyXw+T0blxuTi1\n\tsS9oUhzuuRHdqRlWKfNNAUbFaM/Zzq9nYtqAel/SGKKNsNJC2NVyDgVJJDH96urEeubcLuXuR\n\tnL12zIC9jzXSGrgI9DZoj8lrf7yu2L/DVQrFq2/LoeggF6xeXasIl3j54N/r7460XnTM/u5E9\n\t14JFpMnpTEFTtxCSoOS4DzLMVzMoPwXZk1xAJ8+zEJGhdOPeN2F8SKc7qF0/LHT848pNNW1ck\n\tJF3VbACZWqBZTBhrMwcN1j/QrcHSmyLjofo59KdXTMfss/TC9d2ZB/Mkhr9y99aJhE6s5XBjv\n\tUP2tNICRTyw/9SUuPMjLu6zg2pEPtgbyfsl5Y8cKvmlZE+VLqbQ+OjBhGz7N7H/Ieex4U6xwF\n\tduz5wuJtR46/f8PEZbCtKc64NKuUY6ky+sWhesIZ+l7vvM6Y/c9AHW4N4tlyJyFalVn1XH2pv\n\t3BhtVPgaRkQ7a4xBWjTHATAhM0XWNOdrl6YANkgfCm3f4bUC3u3/F8MMA7+dRCyR80gnLU26M\n\tH7F3syHyxfVC4vZBJS7EeCRAGh0RmgcMu8iBr83GLWJORtFlpn34IFdU8yfjUAHHuRwgsNjx9\n\t/uWTix1SsFQ6LqmH2oY0jSBvlxNK2rwe8VwoAA==","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"With CONFIG_KASAN, the init function uses a large amount of kernel stack:\n\ndrivers/media/usb/em28xx/em28xx-dvb.c: In function 'em28xx_dvb_init.part.4':\ndrivers/media/usb/em28xx/em28xx-dvb.c:2061:1: error: the frame size of 3232 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]\n\nIt seems that this is triggered in part by using strlcpy(), which the\ncompiler doesn't recognize as copying at most 'len' bytes, since strlcpy\nis not part of the C standard.\n\nIt does however recognize the standard strncpy() and optimizes away\nthe extra checks for that, using only 1688 bytes in the end.\nI have another larger patch that we could use in addition to this one,\nin order to shrink the stack for -fsanitize-address-use-after-scope\n(with gcc-7.1.1) as well, but that would not be appropriate for\nstable backports, so let's focus on this one first.\n\nCc: stable@vger.kernel.org\nSigned-off-by: Arnd Bergmann <arnd@arndb.de>\n---\n drivers/media/usb/em28xx/em28xx-dvb.c | 30 +++++++++++++++---------------\n 1 file changed, 15 insertions(+), 15 deletions(-)","diff":"diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c\nindex 4a7db623fe29..06c363dc55ed 100644\n--- a/drivers/media/usb/em28xx/em28xx-dvb.c\n+++ b/drivers/media/usb/em28xx/em28xx-dvb.c\n@@ -1440,7 +1440,7 @@ static int em28xx_dvb_init(struct em28xx *dev)\n \t\ttda10071_pdata.pll_multiplier = 20,\n \t\ttda10071_pdata.tuner_i2c_addr = 0x14,\n \t\tmemset(&board_info, 0, sizeof(board_info));\n-\t\tstrlcpy(board_info.type, \"tda10071_cx24118\", I2C_NAME_SIZE);\n+\t\tstrncpy(board_info.type, \"tda10071_cx24118\", I2C_NAME_SIZE - 1);\n \t\tboard_info.addr = 0x55;\n \t\tboard_info.platform_data = &tda10071_pdata;\n \t\trequest_module(\"tda10071\");\n@@ -1460,7 +1460,7 @@ static int em28xx_dvb_init(struct em28xx *dev)\n \t\t/* attach SEC */\n \t\ta8293_pdata.dvb_frontend = dvb->fe[0];\n \t\tmemset(&board_info, 0, sizeof(board_info));\n-\t\tstrlcpy(board_info.type, \"a8293\", I2C_NAME_SIZE);\n+\t\tstrncpy(board_info.type, \"a8293\", I2C_NAME_SIZE - 1);\n \t\tboard_info.addr = 0x08;\n \t\tboard_info.platform_data = &a8293_pdata;\n \t\trequest_module(\"a8293\");\n@@ -1643,7 +1643,7 @@ static int em28xx_dvb_init(struct em28xx *dev)\n \t\tm88ds3103_pdata.ts_clk_pol = 1;\n \t\tm88ds3103_pdata.agc = 0x99;\n \t\tmemset(&board_info, 0, sizeof(board_info));\n-\t\tstrlcpy(board_info.type, \"m88ds3103\", I2C_NAME_SIZE);\n+\t\tstrncpy(board_info.type, \"m88ds3103\", I2C_NAME_SIZE - 1);\n \t\tboard_info.addr = 0x68;\n \t\tboard_info.platform_data = &m88ds3103_pdata;\n \t\trequest_module(\"m88ds3103\");\n@@ -1664,7 +1664,7 @@ static int em28xx_dvb_init(struct em28xx *dev)\n \t\t/* attach tuner */\n \t\tts2020_config.fe = dvb->fe[0];\n \t\tmemset(&board_info, 0, sizeof(board_info));\n-\t\tstrlcpy(board_info.type, \"ts2022\", I2C_NAME_SIZE);\n+\t\tstrncpy(board_info.type, \"ts2022\", I2C_NAME_SIZE - 1);\n \t\tboard_info.addr = 0x60;\n \t\tboard_info.platform_data = &ts2020_config;\n \t\trequest_module(\"ts2020\");\n@@ -1690,7 +1690,7 @@ static int em28xx_dvb_init(struct em28xx *dev)\n \t\t/* attach SEC */\n \t\ta8293_pdata.dvb_frontend = dvb->fe[0];\n \t\tmemset(&board_info, 0, sizeof(board_info));\n-\t\tstrlcpy(board_info.type, \"a8293\", I2C_NAME_SIZE);\n+\t\tstrncpy(board_info.type, \"a8293\", I2C_NAME_SIZE - 1);\n \t\tboard_info.addr = 0x08;\n \t\tboard_info.platform_data = &a8293_pdata;\n \t\trequest_module(\"a8293\");\n@@ -1729,7 +1729,7 @@ static int em28xx_dvb_init(struct em28xx *dev)\n \t\t\tsi2168_config.fe = &dvb->fe[0];\n \t\t\tsi2168_config.ts_mode = SI2168_TS_PARALLEL;\n \t\t\tmemset(&info, 0, sizeof(struct i2c_board_info));\n-\t\t\tstrlcpy(info.type, \"si2168\", I2C_NAME_SIZE);\n+\t\t\tstrncpy(info.type, \"si2168\", I2C_NAME_SIZE - 1);\n \t\t\tinfo.addr = 0x64;\n \t\t\tinfo.platform_data = &si2168_config;\n \t\t\trequest_module(info.type);\n@@ -1755,7 +1755,7 @@ static int em28xx_dvb_init(struct em28xx *dev)\n \t\t\tsi2157_config.mdev = dev->media_dev;\n #endif\n \t\t\tmemset(&info, 0, sizeof(struct i2c_board_info));\n-\t\t\tstrlcpy(info.type, \"si2157\", I2C_NAME_SIZE);\n+\t\t\tstrncpy(info.type, \"si2157\", I2C_NAME_SIZE - 1);\n \t\t\tinfo.addr = 0x60;\n \t\t\tinfo.platform_data = &si2157_config;\n \t\t\trequest_module(info.type);\n@@ -1793,7 +1793,7 @@ static int em28xx_dvb_init(struct em28xx *dev)\n \t\t\tsi2168_config.fe = &dvb->fe[0];\n \t\t\tsi2168_config.ts_mode = SI2168_TS_PARALLEL;\n \t\t\tmemset(&info, 0, sizeof(struct i2c_board_info));\n-\t\t\tstrlcpy(info.type, \"si2168\", I2C_NAME_SIZE);\n+\t\t\tstrncpy(info.type, \"si2168\", I2C_NAME_SIZE - 1);\n \t\t\tinfo.addr = 0x64;\n \t\t\tinfo.platform_data = &si2168_config;\n \t\t\trequest_module(info.type);\n@@ -1819,7 +1819,7 @@ static int em28xx_dvb_init(struct em28xx *dev)\n \t\t\tsi2157_config.mdev = dev->media_dev;\n #endif\n \t\t\tmemset(&info, 0, sizeof(struct i2c_board_info));\n-\t\t\tstrlcpy(info.type, \"si2146\", I2C_NAME_SIZE);\n+\t\t\tstrncpy(info.type, \"si2146\", I2C_NAME_SIZE - 1);\n \t\t\tinfo.addr = 0x60;\n \t\t\tinfo.platform_data = &si2157_config;\n \t\t\trequest_module(\"si2157\");\n@@ -1853,7 +1853,7 @@ static int em28xx_dvb_init(struct em28xx *dev)\n \t\t\t/* attach demod */\n \t\t\tmemset(&tc90522_config, 0, sizeof(tc90522_config));\n \t\t\tmemset(&info, 0, sizeof(struct i2c_board_info));\n-\t\t\tstrlcpy(info.type, \"tc90522sat\", I2C_NAME_SIZE);\n+\t\t\tstrncpy(info.type, \"tc90522sat\", I2C_NAME_SIZE - 1);\n \t\t\tinfo.addr = 0x15;\n \t\t\tinfo.platform_data = &tc90522_config;\n \t\t\trequest_module(\"tc90522\");\n@@ -1875,7 +1875,7 @@ static int em28xx_dvb_init(struct em28xx *dev)\n \t\t\tqm1d1c0042_config.fe = tc90522_config.fe;\n \t\t\tqm1d1c0042_config.lpf = 1;\n \t\t\tmemset(&info, 0, sizeof(struct i2c_board_info));\n-\t\t\tstrlcpy(info.type, \"qm1d1c0042\", I2C_NAME_SIZE);\n+\t\t\tstrncpy(info.type, \"qm1d1c0042\", I2C_NAME_SIZE - 1);\n \t\t\tinfo.addr = 0x61;\n \t\t\tinfo.platform_data = &qm1d1c0042_config;\n \t\t\trequest_module(info.type);\n@@ -1913,7 +1913,7 @@ static int em28xx_dvb_init(struct em28xx *dev)\n \t\t\tsi2168_config.fe = &dvb->fe[0];\n \t\t\tsi2168_config.ts_mode = SI2168_TS_SERIAL;\n \t\t\tmemset(&info, 0, sizeof(struct i2c_board_info));\n-\t\t\tstrlcpy(info.type, \"si2168\", I2C_NAME_SIZE);\n+\t\t\tstrncpy(info.type, \"si2168\", I2C_NAME_SIZE - 1);\n \t\t\tinfo.addr = 0x64;\n \t\t\tinfo.platform_data = &si2168_config;\n \t\t\trequest_module(info.type);\n@@ -1939,7 +1939,7 @@ static int em28xx_dvb_init(struct em28xx *dev)\n \t\t\tsi2157_config.mdev = dev->media_dev;\n #endif\n \t\t\tmemset(&info, 0, sizeof(struct i2c_board_info));\n-\t\t\tstrlcpy(info.type, \"si2157\", I2C_NAME_SIZE);\n+\t\t\tstrncpy(info.type, \"si2157\", I2C_NAME_SIZE - 1);\n \t\t\tinfo.addr = 0x60;\n \t\t\tinfo.platform_data = &si2157_config;\n \t\t\trequest_module(info.type);\n@@ -1975,7 +1975,7 @@ static int em28xx_dvb_init(struct em28xx *dev)\n \t\t\tlgdt3306a_config = hauppauge_01595_lgdt3306a_config;\n \t\t\tlgdt3306a_config.fe = &dvb->fe[0];\n \t\t\tlgdt3306a_config.i2c_adapter = &adapter;\n-\t\t\tstrlcpy(info.type, \"lgdt3306a\", sizeof(info.type));\n+\t\t\tstrncpy(info.type, \"lgdt3306a\", sizeof(info.type) - 1);\n \t\t\tinfo.addr = 0x59;\n \t\t\tinfo.platform_data = &lgdt3306a_config;\n \t\t\trequest_module(info.type);\n@@ -2002,7 +2002,7 @@ static int em28xx_dvb_init(struct em28xx *dev)\n \t\t\tsi2157_config.mdev = dev->media_dev;\n #endif\n \t\t\tmemset(&info, 0, sizeof(struct i2c_board_info));\n-\t\t\tstrlcpy(info.type, \"si2157\", sizeof(info.type));\n+\t\t\tstrncpy(info.type, \"si2157\", sizeof(info.type) - 1);\n \t\t\tinfo.addr = 0x60;\n \t\t\tinfo.platform_data = &si2157_config;\n \t\t\trequest_module(info.type);\n","prefixes":["v4","4/9"]}