android_kernel_oneplus_msm8998/drivers/net/wan
Arnd Bergmann 6e6ede49a9 farsync: fix off-by-one bug in fst_add_one
[ Upstream commit e725a66c0202b5f36c2f9d59d26a65c53bbf21f7 ]

gcc-6 finds an out of bounds access in the fst_add_one function
when calculating the end of the mmio area:

drivers/net/wan/farsync.c: In function 'fst_add_one':
drivers/net/wan/farsync.c:418:53: error: index 2 denotes an offset greater than size of 'u8[2][8192] {aka unsigned char[2][8192]}' [-Werror=array-bounds]
 #define BUF_OFFSET(X)   (BFM_BASE + offsetof(struct buf_window, X))
                                                     ^
include/linux/compiler-gcc.h:158:21: note: in definition of macro '__compiler_offsetof'
  __builtin_offsetof(a, b)
                     ^
drivers/net/wan/farsync.c:418:37: note: in expansion of macro 'offsetof'
 #define BUF_OFFSET(X)   (BFM_BASE + offsetof(struct buf_window, X))
                                     ^~~~~~~~
drivers/net/wan/farsync.c:2519:36: note: in expansion of macro 'BUF_OFFSET'
                                  + BUF_OFFSET ( txBuffer[i][NUM_TX_BUFFER][0]);
                                    ^~~~~~~~~~

The warning is correct, but not critical because this appears
to be a write-only variable that is set by each WAN driver but
never accessed afterwards.

I'm taking the minimal fix here, using the correct pointer by
pointing 'mem_end' to the last byte inside of the register area
as all other WAN drivers do, rather than the first byte outside of
it. An alternative would be to just remove the mem_end member
entirely.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-20 15:42:03 +09:00
..
lmc
.gitignore
c101.c
cosa.c cosa: missing error code on failure in probe() 2015-08-12 16:53:11 -07:00
cosa.h
dlci.c
dscc4.c wan: dscc4: use msecs_to_jiffies for conversions 2015-06-07 23:45:39 -07:00
farsync.c farsync: fix off-by-one bug in fst_add_one 2016-04-20 15:42:03 +09:00
farsync.h
hd64570.c
hd64570.h
hd64572.c
hd64572.h
hdlc.c
hdlc_cisco.c
hdlc_fr.c hdlc: fix null-deref on allocation failure 2015-11-18 14:58:03 -05:00
hdlc_ppp.c
hdlc_raw.c
hdlc_raw_eth.c
hdlc_x25.c
hostess_sv11.c
ixp4xx_hss.c
Kconfig
lapbether.c netfilter: Remove spurios included of netfilter.h 2015-06-18 21:14:32 +02:00
Makefile
n2.c
pc300too.c
pci200syn.c
sbni.c net: wan: sbni: fix device usage count 2015-09-05 17:32:53 -07:00
sbni.h
sdla.c
sealevel.c
wanxl.c
wanxl.h
wanxlfw.inc_shipped
wanxlfw.S
x25_asy.c wan/x25: Fix use-after-free in x25_asy_open_tty() 2015-12-01 15:17:42 -05:00
x25_asy.h
z85230.c Doc: z8530book: Fix typo in API-z8530-sync-txdma-open.html 2015-07-10 23:45:31 -07:00
z85230.h