From patchwork Thu Nov 30 11:08:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 120136 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp523202qgn; Thu, 30 Nov 2017 03:10:38 -0800 (PST) X-Google-Smtp-Source: AGs4zMbSsPnesKfoabzMW5ie2drWiq9zAMa8qdgSELreQAbE5CbCUJ/nZXDjDMFE3XlPrLHNuXY2 X-Received: by 10.101.72.132 with SMTP id n4mr1987230pgs.288.1512040238887; Thu, 30 Nov 2017 03:10:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512040238; cv=none; d=google.com; s=arc-20160816; b=Q18s1y+8r7CwuuMPKbmxnlotYbiAkWmYEgd5q8iuRLf8Q6tDyXXyl13ClCDky5mzC7 3CgLp9UP+0qMgazCKZr+tGWG7RcA3BQsMrMYPVwcXW5ePFD6extPfa1TqBUh1WUDfkrT Ql8L8OQNInDlnuPe4+n49n21309Dpv/3HC1PQKCK3DPkcg2bSaroZZbtReTaP9DbuoY+ AEcU08cuky3lrGiltJFLjQrY6XnA3tlQvA66Ft+HsKofKWpoyV1N9JjuvxEb1p6oTYWN ZflzAufFrEgmy4ef8/n/kqk/q2m22SqPKD2/hm7teTZ7k5nU4ZrKRVNdGv1Y9EqIfedy 6hZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=1QloaB2nuhlaJ+GmAvmhTUbhYbo6/lW9S8bV+VqTf4A=; b=rmdUOTjD9LN04qSh21cWOnGWFlPYFh6w7OpOdo99XvTwjGCKGR7x1/IwVUMfQUehEc 9NhmVzTDLWH6bcMG1w3gVWMiAvZcEsISWPFDkI94HlssSaYMWurpMcAVPXbrlarSCpfp FV+SP2J75Jto48t2HyDUA19RRxIJWiCG2U22/YOVp8REyM3g1XDArorY0n22PQUHn2H9 qvgZUgFm99GcPUQjaa8Vw/J5d6GM40OWUj2gbwfQZ96IEX+3me89PgXDolixfX7+0nQN 0Sem8UB0NJLRRuR73/rXhllQ9eEFoQZUTH/p9KjSxgXDeshowxtW+PloivXW4re+uk+n HxTw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 h3si2944839plh.208.2017.11.30.03.10.38; Thu, 30 Nov 2017 03:10:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752252AbdK3LKh (ORCPT + 26 others); Thu, 30 Nov 2017 06:10:37 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:50112 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751980AbdK3LKe (ORCPT ); Thu, 30 Nov 2017 06:10:34 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0LpkJD-1en71x06pb-00fmo8; Thu, 30 Nov 2017 12:09:46 +0100 From: Arnd Bergmann To: Mauro Carvalho Chehab Cc: Arnd Bergmann , stable@vger.kernel.org, Sergey Kozlov , Abylay Ospan , Daniel Scheller , Alexey Dobriyan , Masanari Iida , Jiri Kosina , Randy Dunlap , Sakari Ailus , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH, RESEND 1/2] dvb-frontends: fix i2c access helpers for KASAN Date: Thu, 30 Nov 2017 12:08:04 +0100 Message-Id: <20171130110939.1140969-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:f4Pa9/9NM2Dr8dzG9Lg1V6J87+3E9rXG0CJIumqyGDjnkvTT9Dc 0bCqGHO0ZnI0LXeu9bb1M+3yYWa4IHEkpyccdKle3y2BNNFZvqcLrvkwwURwu/+ZtxNyDYC h6JHrfYckTWD2SEZa5eLe9HEIMjWiIY1eoESHvQQLtaLV++PmX4OIwSP+3xhEMSw4fTK4D8 yN//tUllvh1x51IU0zv6Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:2a1D/NJHEWU=:MawuaSNiQBMwtipATJ1S9r Io7ATSOHRxONGeRT82S6ud78zMQFvRkeNFmBhLLswUmfE+aszpPa1jhokkMYz1Oj1uqSUBuJJ 4kd4yLswFBAJO9isOtWhd12xRY57GUsiyRHcFnv633Bcv0llmS2Z9zNMmLnuH2XEiSR88pBQh 6s9X8uoUHbOqmz/ch2lKLnWQjajU6SorPVa2X9ezbx68hjsdoldl2aXtX+y6ogLXS1JQPMFz/ Ss84sRX4/vMlYzBLToc9H6qPmk0ZRUterWL/J+cIxPzkDRpH3vMLU9/7xbj19yRQTDwhBpuRN SvVquklUYuVdytrMdy340RCjF8eGsEvrIPda0eP3htMNf5h4jvtBt5Q17JRp8HiOBtY1JXhHM hxmbw+Uy7mC9PDSoeL0RxKlmdf+wwFSyFKzM/NUfXhAC6rdpM1W+tmtKUlKkpN/JMzaTKJQxz 0gqqoLTkAsKwdmqgQFbFT/+/DeqRq8qbdcx+K1NCATLHGFCeHHJ8QnQY+hn1XxltkuKapz4uD rDIiZk2YoFa+XUq7n6XLjB+pIWOF1CbNmi51aKtKYSfhWYrpREgyQ7JYfu5DbR9LoCT2qfiXW NRYzX5j72xjD46QFG2hcXM78pY56EBZpVaompRdos1JlEd7pOTpN4eCE68wWGV+ll7dFe3o/r NaiK2eHaFfMVp9IKSLlRz91mVW3Q9i9FHvi0R6L/q3wrJK6u8WBGWdYXpU4khbm0QouHKREW7 nn4Jyvu+wUrGJ+MmEmAWkfeYSNMZFPFise6lte7j7Pb4gGKEAWdUemxwsME= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A typical code fragment was copied across many dvb-frontend drivers and causes large stack frames when built with with CONFIG_KASAN on gcc-5/6/7: drivers/media/dvb-frontends/cxd2841er.c:3225:1: error: the frame size of 3992 bytes is larger than 3072 bytes [-Werror=frame-larger-than=] drivers/media/dvb-frontends/cxd2841er.c:3404:1: error: the frame size of 3136 bytes is larger than 3072 bytes [-Werror=frame-larger-than=] drivers/media/dvb-frontends/stv0367.c:3143:1: error: the frame size of 4016 bytes is larger than 3072 bytes [-Werror=frame-larger-than=] drivers/media/dvb-frontends/stv090x.c:3430:1: error: the frame size of 5312 bytes is larger than 3072 bytes [-Werror=frame-larger-than=] drivers/media/dvb-frontends/stv090x.c:4248:1: error: the frame size of 4872 bytes is larger than 3072 bytes [-Werror=frame-larger-than=] gcc-8 now solves this by consolidating the stack slots for the argument variables, but on older compilers we can get the same behavior by taking the pointer of a local variable rather than the inline function argument. Cc: stable@vger.kernel.org Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 Signed-off-by: Arnd Bergmann --- I'm undecided here whether there should be a comment pointing to PR81715 for each file that the bogus local variable workaround to prevent it from being cleaned up again. It's probably not necessary since anything that causes actual problems would also trigger a build warning. --- drivers/media/dvb-frontends/ascot2e.c | 4 +++- drivers/media/dvb-frontends/cxd2841er.c | 4 +++- drivers/media/dvb-frontends/helene.c | 4 +++- drivers/media/dvb-frontends/horus3a.c | 4 +++- drivers/media/dvb-frontends/itd1000.c | 5 +++-- drivers/media/dvb-frontends/mt312.c | 4 +++- drivers/media/dvb-frontends/stb0899_drv.c | 3 ++- drivers/media/dvb-frontends/stb6100.c | 6 ++++-- drivers/media/dvb-frontends/stv0367.c | 4 +++- drivers/media/dvb-frontends/stv090x.c | 4 +++- drivers/media/dvb-frontends/stv6110x.c | 4 +++- drivers/media/dvb-frontends/zl10039.c | 4 +++- 12 files changed, 36 insertions(+), 14 deletions(-) -- 2.9.0 diff --git a/drivers/media/dvb-frontends/ascot2e.c b/drivers/media/dvb-frontends/ascot2e.c index 0ee0df53b91b..1219272ca3f0 100644 --- a/drivers/media/dvb-frontends/ascot2e.c +++ b/drivers/media/dvb-frontends/ascot2e.c @@ -155,7 +155,9 @@ static int ascot2e_write_regs(struct ascot2e_priv *priv, static int ascot2e_write_reg(struct ascot2e_priv *priv, u8 reg, u8 val) { - return ascot2e_write_regs(priv, reg, &val, 1); + u8 tmp = val; + + return ascot2e_write_regs(priv, reg, &tmp, 1); } static int ascot2e_read_regs(struct ascot2e_priv *priv, diff --git a/drivers/media/dvb-frontends/cxd2841er.c b/drivers/media/dvb-frontends/cxd2841er.c index 48ee9bc00c06..b7574deff5c6 100644 --- a/drivers/media/dvb-frontends/cxd2841er.c +++ b/drivers/media/dvb-frontends/cxd2841er.c @@ -257,7 +257,9 @@ static int cxd2841er_write_regs(struct cxd2841er_priv *priv, static int cxd2841er_write_reg(struct cxd2841er_priv *priv, u8 addr, u8 reg, u8 val) { - return cxd2841er_write_regs(priv, addr, reg, &val, 1); + u8 tmp = val; + + return cxd2841er_write_regs(priv, addr, reg, &tmp, 1); } static int cxd2841er_read_regs(struct cxd2841er_priv *priv, diff --git a/drivers/media/dvb-frontends/helene.c b/drivers/media/dvb-frontends/helene.c index 4bf5a551ba40..6e93f2d1575b 100644 --- a/drivers/media/dvb-frontends/helene.c +++ b/drivers/media/dvb-frontends/helene.c @@ -331,7 +331,9 @@ static int helene_write_regs(struct helene_priv *priv, static int helene_write_reg(struct helene_priv *priv, u8 reg, u8 val) { - return helene_write_regs(priv, reg, &val, 1); + u8 tmp = val; + + return helene_write_regs(priv, reg, &tmp, 1); } static int helene_read_regs(struct helene_priv *priv, diff --git a/drivers/media/dvb-frontends/horus3a.c b/drivers/media/dvb-frontends/horus3a.c index 68d759c4c52e..fa9e2d373073 100644 --- a/drivers/media/dvb-frontends/horus3a.c +++ b/drivers/media/dvb-frontends/horus3a.c @@ -89,7 +89,9 @@ static int horus3a_write_regs(struct horus3a_priv *priv, static int horus3a_write_reg(struct horus3a_priv *priv, u8 reg, u8 val) { - return horus3a_write_regs(priv, reg, &val, 1); + u8 tmp = val; + + return horus3a_write_regs(priv, reg, &tmp, 1); } static int horus3a_enter_power_save(struct horus3a_priv *priv) diff --git a/drivers/media/dvb-frontends/itd1000.c b/drivers/media/dvb-frontends/itd1000.c index 5bb1e73a10b4..1ac5177162f6 100644 --- a/drivers/media/dvb-frontends/itd1000.c +++ b/drivers/media/dvb-frontends/itd1000.c @@ -95,8 +95,9 @@ static int itd1000_read_reg(struct itd1000_state *state, u8 reg) static inline int itd1000_write_reg(struct itd1000_state *state, u8 r, u8 v) { - int ret = itd1000_write_regs(state, r, &v, 1); - state->shadow[r] = v; + u8 tmp = v; + int ret = itd1000_write_regs(state, r, &tmp, 1); + state->shadow[r] = tmp; return ret; } diff --git a/drivers/media/dvb-frontends/mt312.c b/drivers/media/dvb-frontends/mt312.c index 961b9a2508e0..12c32c024252 100644 --- a/drivers/media/dvb-frontends/mt312.c +++ b/drivers/media/dvb-frontends/mt312.c @@ -142,7 +142,9 @@ static inline int mt312_readreg(struct mt312_state *state, static inline int mt312_writereg(struct mt312_state *state, const enum mt312_reg_addr reg, const u8 val) { - return mt312_write(state, reg, &val, 1); + u8 tmp = val; + + return mt312_write(state, reg, &tmp, 1); } static inline u32 mt312_div(u32 a, u32 b) diff --git a/drivers/media/dvb-frontends/stb0899_drv.c b/drivers/media/dvb-frontends/stb0899_drv.c index 02347598277a..db5dde3215f0 100644 --- a/drivers/media/dvb-frontends/stb0899_drv.c +++ b/drivers/media/dvb-frontends/stb0899_drv.c @@ -539,7 +539,8 @@ int stb0899_write_regs(struct stb0899_state *state, unsigned int reg, u8 *data, int stb0899_write_reg(struct stb0899_state *state, unsigned int reg, u8 data) { - return stb0899_write_regs(state, reg, &data, 1); + u8 tmp = data; + return stb0899_write_regs(state, reg, &tmp, 1); } /* diff --git a/drivers/media/dvb-frontends/stb6100.c b/drivers/media/dvb-frontends/stb6100.c index 17a955d0031b..0167a3e1ecc5 100644 --- a/drivers/media/dvb-frontends/stb6100.c +++ b/drivers/media/dvb-frontends/stb6100.c @@ -226,12 +226,14 @@ static int stb6100_write_reg_range(struct stb6100_state *state, u8 buf[], int st static int stb6100_write_reg(struct stb6100_state *state, u8 reg, u8 data) { + u8 tmp = data; + if (unlikely(reg >= STB6100_NUMREGS)) { dprintk(verbose, FE_ERROR, 1, "Invalid register offset 0x%x", reg); return -EREMOTEIO; } - data = (data & stb6100_template[reg].mask) | stb6100_template[reg].set; - return stb6100_write_reg_range(state, &data, reg, 1); + tmp = (tmp & stb6100_template[reg].mask) | stb6100_template[reg].set; + return stb6100_write_reg_range(state, &tmp, reg, 1); } diff --git a/drivers/media/dvb-frontends/stv0367.c b/drivers/media/dvb-frontends/stv0367.c index f3529df8211d..1964cb7d58b7 100644 --- a/drivers/media/dvb-frontends/stv0367.c +++ b/drivers/media/dvb-frontends/stv0367.c @@ -166,7 +166,9 @@ int stv0367_writeregs(struct stv0367_state *state, u16 reg, u8 *data, int len) static int stv0367_writereg(struct stv0367_state *state, u16 reg, u8 data) { - return stv0367_writeregs(state, reg, &data, 1); + u8 tmp = data; + + return stv0367_writeregs(state, reg, &tmp, 1); } static u8 stv0367_readreg(struct stv0367_state *state, u16 reg) diff --git a/drivers/media/dvb-frontends/stv090x.c b/drivers/media/dvb-frontends/stv090x.c index 7ef469c0c866..85ec19305483 100644 --- a/drivers/media/dvb-frontends/stv090x.c +++ b/drivers/media/dvb-frontends/stv090x.c @@ -755,7 +755,9 @@ static int stv090x_write_regs(struct stv090x_state *state, unsigned int reg, u8 static int stv090x_write_reg(struct stv090x_state *state, unsigned int reg, u8 data) { - return stv090x_write_regs(state, reg, &data, 1); + u8 tmp = data; + + return stv090x_write_regs(state, reg, &tmp, 1); } static int stv090x_i2c_gate_ctrl(struct stv090x_state *state, int enable) diff --git a/drivers/media/dvb-frontends/stv6110x.c b/drivers/media/dvb-frontends/stv6110x.c index 66eba38f1014..f0fd9605aa77 100644 --- a/drivers/media/dvb-frontends/stv6110x.c +++ b/drivers/media/dvb-frontends/stv6110x.c @@ -97,7 +97,9 @@ static int stv6110x_write_regs(struct stv6110x_state *stv6110x, int start, u8 da static int stv6110x_write_reg(struct stv6110x_state *stv6110x, u8 reg, u8 data) { - return stv6110x_write_regs(stv6110x, reg, &data, 1); + u8 tmp = data; + + return stv6110x_write_regs(stv6110x, reg, &tmp, 1); } static int stv6110x_init(struct dvb_frontend *fe) diff --git a/drivers/media/dvb-frontends/zl10039.c b/drivers/media/dvb-frontends/zl10039.c index 623355fc2666..4ec9a8fb8c12 100644 --- a/drivers/media/dvb-frontends/zl10039.c +++ b/drivers/media/dvb-frontends/zl10039.c @@ -134,7 +134,9 @@ static inline int zl10039_writereg(struct zl10039_state *state, const enum zl10039_reg_addr reg, const u8 val) { - return zl10039_write(state, reg, &val, 1); + const u8 tmp = val; + + return zl10039_write(state, reg, &tmp, 1); } static int zl10039_init(struct dvb_frontend *fe)