From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Chang-Hsien Tsai <luke.tw@gmail.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Sasha Levin <sashal@kernel.org>,
netdev@vger.kernel.org, bpf@vger.kernel.org
Subject: [PATCH AUTOSEL 4.4 02/12] samples, bpf: fix to change the buffer size for read()
Date: Wed, 26 Jun 2019 20:42:24 -0400 [thread overview]
Message-ID: <20190627004236.21909-2-sashal@kernel.org> (raw)
In-Reply-To: <20190627004236.21909-1-sashal@kernel.org>
From: Chang-Hsien Tsai <luke.tw@gmail.com>
[ 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>
---
samples/bpf/bpf_load.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/samples/bpf/bpf_load.c b/samples/bpf/bpf_load.c
index da86a8e0a95a..e836b5ff2060 100644
--- a/samples/bpf/bpf_load.c
+++ b/samples/bpf/bpf_load.c
@@ -336,7 +336,7 @@ void read_trace_pipe(void)
static char buf[4096];
ssize_t sz;
- sz = read(trace_fd, buf, sizeof(buf));
+ sz = read(trace_fd, buf, sizeof(buf) - 1);
if (sz > 0) {
buf[sz] = 0;
puts(buf);
--
2.20.1
next prev parent reply other threads:[~2019-06-27 0:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-27 0:42 [PATCH AUTOSEL 4.4 01/12] Input: elantech - enable middle button support on 2 ThinkPads Sasha Levin
2019-06-27 0:42 ` Sasha Levin [this message]
2019-06-27 0:42 ` [PATCH AUTOSEL 4.4 03/12] mac80211: mesh: fix RCU warning Sasha Levin
2019-06-27 0:42 ` [PATCH AUTOSEL 4.4 04/12] mwifiex: Fix possible buffer overflows at parsing bss descriptor Sasha Levin
2019-06-27 0:42 ` [PATCH AUTOSEL 4.4 05/12] mwifiex: Abort at too short BSS descriptor element Sasha Levin
2019-06-27 0:42 ` [PATCH AUTOSEL 4.4 06/12] dt-bindings: can: mcp251x: add mcp25625 support Sasha Levin
2019-06-27 0:42 ` [PATCH AUTOSEL 4.4 07/12] can: mcp251x: add support for mcp25625 Sasha Levin
2019-06-27 0:42 ` [PATCH AUTOSEL 4.4 08/12] Input: imx_keypad - make sure keyboard can always wake up system Sasha Levin
2019-06-27 0:42 ` [PATCH AUTOSEL 4.4 09/12] ARM: davinci: da850-evm: call regulator_has_full_constraints() Sasha Levin
2019-06-27 0:42 ` [PATCH AUTOSEL 4.4 10/12] ARM: davinci: da8xx: specify dma_coherent_mask for lcdc Sasha Levin
2019-06-27 0:42 ` [PATCH AUTOSEL 4.4 11/12] md: fix for divide error in status_resync Sasha Levin
2019-06-27 0:42 ` [PATCH AUTOSEL 4.4 12/12] bnx2x: Check if transceiver implements DDM before access Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190627004236.21909-2-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=linux-kernel@vger.kernel.org \
--cc=luke.tw@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.