Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1591310

[PATCH 15/26] [media] tuners: i2c: reduce stack usage for tuner_i2c_xfer_*

From Arnd Bergmann <arnd@arndb.de>
Newsgroups linux.kernel
Subject [PATCH 15/26] [media] tuners: i2c: reduce stack usage for tuner_i2c_xfer_*
Date 2017-03-02 18:20 +0100
Message-ID <tgCyu-5uu-27@gated-at.bofh.it> (permalink)
References <tgCf7-56J-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


When CONFIG_KASAN is enabled, we see very large stack usage in some
functions, e.g.:

drivers/media/tuners/tda8290.c: In function 'tda8290_set_params':
drivers/media/tuners/tda8290.c:310:1: warning: the frame size of 3184 bytes is larger than 1024 bytes [-Wframe-larger-than=]
drivers/media/tuners/tda8290.c: In function 'tda829x_probe':
drivers/media/tuners/tda8290.c:878:1: warning: the frame size of 1088 bytes is larger than 1024 bytes [-Wframe-larger-than=]

By annotating the helpers as noinline_for_kasan, we can easily avoid this.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/media/tuners/tuner-i2c.h | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/media/tuners/tuner-i2c.h b/drivers/media/tuners/tuner-i2c.h
index bda67a5a76f2..c8970299799c 100644
--- a/drivers/media/tuners/tuner-i2c.h
+++ b/drivers/media/tuners/tuner-i2c.h
@@ -33,8 +33,8 @@ struct tuner_i2c_props {
 	char *name;
 };
 
-static inline int tuner_i2c_xfer_send(struct tuner_i2c_props *props,
-				      unsigned char *buf, int len)
+static noinline_for_kasan int
+tuner_i2c_xfer_send(struct tuner_i2c_props *props, unsigned char *buf, int len)
 {
 	struct i2c_msg msg = { .addr = props->addr, .flags = 0,
 			       .buf = buf, .len = len };
@@ -43,8 +43,8 @@ static inline int tuner_i2c_xfer_send(struct tuner_i2c_props *props,
 	return (ret == 1) ? len : ret;
 }
 
-static inline int tuner_i2c_xfer_recv(struct tuner_i2c_props *props,
-				      unsigned char *buf, int len)
+static noinline_for_kasan int
+tuner_i2c_xfer_recv(struct tuner_i2c_props *props, unsigned char *buf, int len)
 {
 	struct i2c_msg msg = { .addr = props->addr, .flags = I2C_M_RD,
 			       .buf = buf, .len = len };
@@ -53,9 +53,10 @@ static inline int tuner_i2c_xfer_recv(struct tuner_i2c_props *props,
 	return (ret == 1) ? len : ret;
 }
 
-static inline int tuner_i2c_xfer_send_recv(struct tuner_i2c_props *props,
-					   unsigned char *obuf, int olen,
-					   unsigned char *ibuf, int ilen)
+static noinline_for_kasan int
+tuner_i2c_xfer_send_recv(struct tuner_i2c_props *props,
+			 unsigned char *obuf, int olen,
+			 unsigned char *ibuf, int ilen)
 {
 	struct i2c_msg msg[2] = { { .addr = props->addr, .flags = 0,
 				    .buf = obuf, .len = olen },
-- 
2.9.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/26] bring back stack frame warning with KASAN Arnd Bergmann <arnd@arndb.de> - 2017-03-02 18:20 +0100
  [PATCH 07/26] brcmsmac: reduce stack size with KASAN Arnd Bergmann <arnd@arndb.de> - 2017-03-02 18:20 +0100
    Re: [PATCH 07/26] brcmsmac: reduce stack size with KASAN Arend Van Spriel <arend.vanspriel@broadcom.com> - 2017-03-06 10:50 +0100
      Re: [PATCH 07/26] brcmsmac: reduce stack size with KASAN Arnd Bergmann <arnd@arndb.de> - 2017-03-06 12:00 +0100
        Re: [PATCH 07/26] brcmsmac: reduce stack size with KASAN Arend Van Spriel <arend.vanspriel@broadcom.com> - 2017-03-06 12:20 +0100
          Re: [PATCH 07/26] brcmsmac: reduce stack size with KASAN Arnd Bergmann <arnd@arndb.de> - 2017-03-06 12:20 +0100
            Re: [PATCH 07/26] brcmsmac: reduce stack size with KASAN Arnd Bergmann <arnd@arndb.de> - 2017-03-06 12:40 +0100
  [PATCH 15/26] [media] tuners: i2c: reduce stack usage for tuner_i2c_xfer_* Arnd Bergmann <arnd@arndb.de> - 2017-03-02 18:20 +0100
  [PATCH 11/26] rtlwifi: reduce stack usage for KASAN Arnd Bergmann <arnd@arndb.de> - 2017-03-02 18:20 +0100
  [PATCH 04/26] tty: kbd: reduce stack size with KASAN Arnd Bergmann <arnd@arndb.de> - 2017-03-02 18:20 +0100
  [PATCH 12/26] wl3501_cs: reduce stack size for KASAN Arnd Bergmann <arnd@arndb.de> - 2017-03-02 18:20 +0100
  [PATCH 09/26] brcmsmac: split up wlc_phy_workarounds_nphy Arnd Bergmann <arnd@arndb.de> - 2017-03-02 18:20 +0100
    Re: [PATCH 09/26] brcmsmac: split up wlc_phy_workarounds_nphy Arend Van Spriel <arend.vanspriel@broadcom.com> - 2017-03-06 10:40 +0100
  [PATCH 01/26] compiler: introduce noinline_for_kasan annotation Arnd Bergmann <arnd@arndb.de> - 2017-03-02 18:20 +0100
    Re: [PATCH 01/26] compiler: introduce noinline_for_kasan annotation Alexander Potapenko <glider@google.com> - 2017-03-03 15:00 +0100
      Re: [PATCH 01/26] compiler: introduce noinline_for_kasan annotation Alexander Potapenko <glider@google.com> - 2017-03-03 15:40 +0100
        Re: [PATCH 01/26] compiler: introduce noinline_for_kasan annotation Arnd Bergmann <arnd@arndb.de> - 2017-03-03 16:10 +0100
      Re: [PATCH 01/26] compiler: introduce noinline_for_kasan annotation Arnd Bergmann <arnd@arndb.de> - 2017-03-03 15:40 +0100
    RE: [PATCH 01/26] compiler: introduce noinline_for_kasan annotation David Laight <David.Laight@ACULAB.COM> - 2017-03-03 18:10 +0100
  [PATCH 05/26] netlink: mark nla_put_{u8,u16,u32} noinline_for_kasan Arnd Bergmann <arnd@arndb.de> - 2017-03-02 18:20 +0100
  [PATCH 08/26] brcmsmac: make some local variables 'static const' to reduce stack size Arnd Bergmann <arnd@arndb.de> - 2017-03-02 18:20 +0100
    Re: [PATCH 08/26] brcmsmac: make some local variables 'static const'  to reduce stack size Arend Van Spriel <arend.vanspriel@broadcom.com> - 2017-03-06 10:40 +0100
      Re: [PATCH 08/26] brcmsmac: make some local variables 'static const' to reduce stack size Kalle Valo <kvalo@codeaurora.org> - 2017-03-06 17:40 +0100
        Re: [PATCH 08/26] brcmsmac: make some local variables 'static const'  to reduce stack size Arnd Bergmann <arnd@arndb.de> - 2017-03-06 22:40 +0100
          Re: [PATCH 08/26] brcmsmac: make some local variables 'static const' to reduce stack size Kalle Valo <kvalo@codeaurora.org> - 2017-03-07 10:50 +0100
            Re: [PATCH 08/26] brcmsmac: make some local variables 'static const'  to reduce stack size Arend Van Spriel <arend.vanspriel@broadcom.com> - 2017-03-07 11:10 +0100
  [PATCH 22/26] drm/i915/gvt: don't overflow the kernel stack with KASAN Arnd Bergmann <arnd@arndb.de> - 2017-03-02 18:40 +0100
  Re: [PATCH 24/26] ocfs2: reduce stack size with KASAN Joe Perches <joe@perches.com> - 2017-03-02 19:00 +0100
    Re: [PATCH 24/26] ocfs2: reduce stack size with KASAN Joe Perches <joe@perches.com> - 2017-03-02 23:50 +0100
      Re: [PATCH 24/26] ocfs2: reduce stack size with KASAN Arnd Bergmann <arnd@arndb.de> - 2017-03-03 00:10 +0100
        Re: [PATCH 24/26] ocfs2: reduce stack size with KASAN Joe Perches <joe@perches.com> - 2017-03-03 01:00 +0100
    Re: [PATCH 24/26] ocfs2: reduce stack size with KASAN Arnd Bergmann <arnd@arndb.de> - 2017-03-03 00:00 +0100
  [PATCH 24/26] ocfs2: reduce stack size with KASAN Arnd Bergmann <arnd@arndb.de> - 2017-03-02 20:10 +0100
  [PATCH 23/26] mtd: cfi: reduce stack size with KASAN Arnd Bergmann <arnd@arndb.de> - 2017-03-02 20:20 +0100
  [PATCH 18/26] [media] i2c: cx25840: avoid stack overflow with KASAN Arnd Bergmann <arnd@arndb.de> - 2017-03-02 23:30 +0100
  Re: [PATCH 00/26] bring back stack frame warning with KASAN Alexander Potapenko <glider@google.com> - 2017-03-03 13:30 +0100
    Re: [PATCH 00/26] bring back stack frame warning with KASAN Arnd Bergmann <arnd@arndb.de> - 2017-03-03 14:00 +0100
  Re: [PATCH 10/26] brcmsmac: reindent split functions Kalle Valo <kvalo@codeaurora.org> - 2017-03-06 17:50 +0100

csiph-web