]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
samples, bpf: fix to change the buffer size for read()
authorChang-Hsien Tsai <luke.tw@gmail.com>
Sun, 19 May 2019 09:05:44 +0000 (09:05 +0000)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commit144c9f87c6b15320108c0ec07fd89a12ab4277ac
treef8fb066e7cb0b47199c62453d369a6ad939c5862
parent2a781f54fb456237edba648dddbccbed8038c4d1
samples, bpf: fix to change the buffer size for read()

BugLink: https://bugs.launchpad.net/bugs/1839036
[ Upstream commit f7c2d64bac1be2ff32f8e4f500c6e5429c1003e0 ]

If the trace for read is larger than 4096, the return
value sz will be 4096. This results in off-by-one error
on buf:

    static char buf[4096];
    ssize_t sz;

    sz = read(trace_fd, buf, sizeof(buf));
    if (sz > 0) {
        buf[sz] = 0;
        puts(buf);
    }

Signed-off-by: Chang-Hsien Tsai <luke.tw@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
samples/bpf/bpf_load.c