[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1501753.1690920713@warthog.procyon.org.uk>
Date: Tue, 01 Aug 2023 21:11:53 +0100
From: David Howells <dhowells@...hat.com>
To: Willem de Bruijn <willemdebruijn.kernel@...il.com>
Cc: dhowells@...hat.com, netdev@...r.kernel.org,
syzbot+f527b971b4bdc8e79f9e@...kaller.appspotmail.com,
bpf@...r.kernel.org, brauner@...nel.org, davem@...emloft.net,
dsahern@...nel.org, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com, axboe@...nel.dk, viro@...iv.linux.org.uk,
linux-fsdevel@...r.kernel.org, syzkaller-bugs@...glegroups.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net] udp: Fix __ip_append_data()'s handling of MSG_SPLICE_PAGES
Willem de Bruijn <willemdebruijn.kernel@...il.com> wrote:
> __ip6_append_data probably needs the same.
Now that's interesting. __ip6_append_data() has a check for this and returns
-EINVAL in this case:
copy = datalen - transhdrlen - fraggap - pagedlen;
if (copy < 0) {
err = -EINVAL;
goto error;
}
but should I bypass that check for MSG_SPLICE_PAGES? It hits the check when
it should be able to get past it. The code seems to go back to prehistoric
times, so I'm not sure why it's there.
For an 8192 MTU, the breaking point is at a send of 8137 bytes. The attached
test program iterates through different send sizes until it hits the point.
David
---
#define _GNU_SOURCE
#include <arpa/inet.h>
#include <fcntl.h>
#include <netinet/ip6.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/mman.h>
#include <sys/uio.h>
#define OSERROR(R, S) do { if ((long)(R) == -1L) { perror((S)); exit(1); } } while(0)
int main()
{
struct sockaddr_storage ss;
struct sockaddr_in6 sin6;
void *buffer;
unsigned int tmp;
int pfd[2], sfd;
int res, i;
OSERROR(pipe(pfd), "pipe");
sfd = socket(AF_INET6, SOCK_DGRAM, 0);
OSERROR(sfd, "socket/2");
memset(&sin6, 0, sizeof(sin6));
sin6.sin6_family = AF_INET6;
sin6.sin6_port = htons(7);
#warning set dest IPv6 address below
sin6.sin6_addr.s6_addr32[0] = htonl(0x01020304);
sin6.sin6_addr.s6_addr32[1] = htonl(0x05060708);
sin6.sin6_addr.s6_addr32[2] = htonl(0x00000000);
sin6.sin6_addr.s6_addr32[3] = htonl(0x00000001);
OSERROR(connect(sfd, (struct sockaddr *)&sin6, sizeof(sin6)), "connect");
buffer = mmap(NULL, 1024*1024, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0);
OSERROR(buffer, "mmap");
for (i = 1000; i < 65535; i++) {
printf("%d\n", i);
OSERROR(send(sfd, buffer, i, MSG_MORE), "send");
OSERROR(write(pfd[1], buffer, 8), "write");
OSERROR(splice(pfd[0], 0, sfd, 0, 0x4ffe0ul, 0), "splice");
}
return 0;
}
Powered by blists - more mailing lists