Revision da353fac65fede6b8b4cfe207f0d9408e3121105 authored by Daniel Jordan on 27 October 2021, 21:59:20 UTC, committed by David S. Miller on 28 October 2021, 13:41:20 UTC
sk->sk_err appears to expect a positive value, a convention that ktls
doesn't always follow and that leads to memory corruption in other code.
For instance,

    [kworker]
    tls_encrypt_done(..., err=<negative error from crypto request>)
      tls_err_abort(.., err)
        sk->sk_err = err;

    [task]
    splice_from_pipe_feed
      ...
        tls_sw_do_sendpage
          if (sk->sk_err) {
            ret = -sk->sk_err;  // ret is positive

    splice_from_pipe_feed (continued)
      ret = actor(...)  // ret is still positive and interpreted as bytes
                        // written, resulting in underflow of buf->len and
                        // sd->len, leading to huge buf->offset and bogus
                        // addresses computed in later calls to actor()

Fix all tls_err_abort() callers to pass a negative error code
consistently and centralize the error-prone sign flip there, throwing in
a warning to catch future misuse and uninlining the function so it
really does only warn once.

Cc: stable@vger.kernel.org
Fixes: c46234ebb4d1e ("tls: RX path for ktls")
Reported-by: syzbot+b187b77c8474f9648fae@syzkaller.appspotmail.com
Signed-off-by: Daniel Jordan <daniel.m.jordan@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a32f07d
History
File Mode Size
allwinner
amcc
amlogic
axis
bcm
caam
cavium
ccp
ccree
chelsio
gemini
hisilicon
inside-secure
keembay
marvell
nx
qat
qce
rockchip
stm32
ux500
virtio
vmx
xilinx
Kconfig -rw-r--r-- 26.5 KB
Makefile -rw-r--r-- 2.3 KB
atmel-aes-regs.h -rw-r--r-- 3.0 KB
atmel-aes.c -rw-r--r-- 67.2 KB
atmel-authenc.h -rw-r--r-- 1.7 KB
atmel-ecc.c -rw-r--r-- 10.1 KB
atmel-i2c.c -rw-r--r-- 9.9 KB
atmel-i2c.h -rw-r--r-- 5.9 KB
atmel-sha-regs.h -rw-r--r-- 2.4 KB
atmel-sha.c -rw-r--r-- 66.3 KB
atmel-sha204a.c -rw-r--r-- 4.0 KB
atmel-tdes-regs.h -rw-r--r-- 2.7 KB
atmel-tdes.c -rw-r--r-- 30.7 KB
exynos-rng.c -rw-r--r-- 9.2 KB
geode-aes.c -rw-r--r-- 10.5 KB
geode-aes.h -rw-r--r-- 1.2 KB
hifn_795x.c -rw-r--r-- 74.4 KB
img-hash.c -rw-r--r-- 27.1 KB
ixp4xx_crypto.c -rw-r--r-- 39.9 KB
mxs-dcp.c -rw-r--r-- 29.2 KB
n2_asm.S -rw-r--r-- 1.8 KB
n2_core.c -rw-r--r-- 50.6 KB
n2_core.h -rw-r--r-- 6.1 KB
omap-aes-gcm.c -rw-r--r-- 9.4 KB
omap-aes.c -rw-r--r-- 30.9 KB
omap-aes.h -rw-r--r-- 6.0 KB
omap-crypto.c -rw-r--r-- 4.7 KB
omap-crypto.h -rw-r--r-- 908 bytes
omap-des.c -rw-r--r-- 26.8 KB
omap-sham.c -rw-r--r-- 53.4 KB
padlock-aes.c -rw-r--r-- 14.5 KB
padlock-sha.c -rw-r--r-- 14.7 KB
qcom-rng.c -rw-r--r-- 4.9 KB
s5p-sss.c -rw-r--r-- 59.2 KB
sa2ul.c -rw-r--r-- 66.4 KB
sa2ul.h -rw-r--r-- 11.9 KB
sahara.c -rw-r--r-- 39.7 KB
talitos.c -rw-r--r-- 103.3 KB
talitos.h -rw-r--r-- 14.9 KB

back to top