From: Frank de Brabander <debrabander@gmail.com>
To: "David S . Miller" <davem@davemloft.net>,
Willem de Bruijn <willemb@google.com>
Cc: netdev@vger.kernel.org, Frank de Brabander <debrabander@gmail.com>
Subject: bug: tpacket_snd can cause data corruption
Date: Wed, 3 Jul 2019 13:07:08 +0200 [thread overview]
Message-ID: <1562152028-2693-1-git-send-email-debrabander@gmail.com> (raw)
In commit 5cd8d46e a fix was applied for data corruption in
tpacket_snd. A selftest was added in commit 358be656 which
validates this fix.
Unfortunately this bug still persists, although since this fix less
likely to trigger. This bug was initially observed using a PACKET_MMAP
application, but can also be seen by tweaking the kernel selftest.
By tweaking the selftest txring_overwrite.c to run
as an infinite loop, the data corruption will still trigger. It
seems to occur faster by generating interrupts (e.g. by plugging
in USB devices). Tested with kernel version 5.2-RC7.
Cause for this bug is still unclear.
Signed-off-by: Frank de Brabander <debrabander@gmail.com>
---
tools/testing/selftests/net/txring_overwrite.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/net/txring_overwrite.c b/tools/testing/selftests/net/txring_overwrite.c
index fd8b1c6..3ee23e5 100644
--- a/tools/testing/selftests/net/txring_overwrite.c
+++ b/tools/testing/selftests/net/txring_overwrite.c
@@ -143,19 +143,22 @@ static int read_verify_pkt(int fdr, char payload_char)
int ret;
ret = read(fdr, buf, sizeof(buf));
- if (ret != sizeof(buf))
- error(1, errno, "read");
+ if (ret != sizeof(buf)) {
+ //error(1, errno, "read");
+ printf("read error\n");
+ return 1;
+ }
if (buf[60] != payload_char) {
printf("wrong pattern: 0x%x != 0x%x\n", buf[60], payload_char);
return 1;
}
- printf("read: %c (0x%x)\n", buf[60], buf[60]);
+ //printf("read: %c (0x%x)\n", buf[60], buf[60]);
return 0;
}
-int main(int argc, char **argv)
+void run_test(void)
{
const char payload_patterns[] = "ab";
char *ring;
@@ -177,3 +180,10 @@ int main(int argc, char **argv)
return ret;
}
+
+int main(int argc, char **argv)
+{
+ while (true) {
+ run_test();
+ }
+}
--
2.7.4
next reply other threads:[~2019-07-03 11:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-03 11:07 Frank de Brabander [this message]
2019-07-03 16:07 ` bug: tpacket_snd can cause data corruption Willem de Bruijn
2019-07-04 10:43 ` Frank de Brabander
2019-07-04 22:59 ` Willem de Bruijn
2019-07-05 7:49 ` Frank de Brabander
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=1562152028-2693-1-git-send-email-debrabander@gmail.com \
--to=debrabander@gmail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=willemb@google.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).