From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Kuniyuki Iwashima <kuniyu@amazon.com>, willemdebruijn.kernel@gmail.com
Cc: davem@davemloft.net, dsahern@kernel.org, edumazet@google.com,
horms@kernel.org, kuba@kernel.org, kuni1840@gmail.com,
kuniyu@amazon.com, netdev@vger.kernel.org, pabeni@redhat.com
Subject: Re: [PATCH v1 net 3/3] selftest: net: Check wraparounds for sk->sk_rmem_alloc.
Date: Mon, 24 Mar 2025 15:31:10 -0400 [thread overview]
Message-ID: <67e1b2fe98de0_35010c2946f@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <20250324182602.47871-1-kuniyu@amazon.com>
Kuniyuki Iwashima wrote:
> From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
> Date: Mon, 24 Mar 2025 11:58:06 -0400
> > > +TEST_F(so_rcvbuf, rmem_max)
> > > +{
> > > + char buf[16] = {};
> > > + int ret, i;
> > > +
> > > + create_socketpair(_metadata, self, variant);
> > > +
> > > + ret = setsockopt(self->server, SOL_SOCKET, SO_RCVBUFFORCE,
> > > + &(int){INT_MAX}, sizeof(int));
> > > + ASSERT_EQ(ret, 0);
> > > +
> > > + ASSERT_EQ(get_prot_pages(_metadata, variant), 0);
> > > +
> > > + for (i = 1; ; i++) {
> > > + ret = send(self->client, buf, sizeof(buf), 0);
> > > + ASSERT_EQ(ret, sizeof(buf));
> > > +
> > > + if (i % 10000 == 0) {
> > > + int pages = get_prot_pages(_metadata, variant);
> > > +
> > > + /* sk_rmem_alloc wrapped around too much ? */
> > > + ASSERT_LE(pages, *variant->max_pages);
> > > +
> > > + if (pages == *variant->max_pages)
> > > + break;
> >
> > Does correctness depend here on max_pages being a multiple of 10K?
>
> 10K may be too conservative, but at least we need to ensure
> that the size of accumulated skbs exceeds 1 PAGE_SIZE to
> fail on the ASSERT_LE(), otherwise we can't detect the multiple
> wraparounds even without patch 1.
Thanks. It took me some time to understand. Without overflow,
the pages counter will saturate at max_pages as the queue fills up.
> The later sleep for call_rcu() was dominant than this loop on
> my machine.
Ack.
prev parent reply other threads:[~2025-03-24 19:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-23 23:09 [PATCH v1 net 0/3] udp: Fix two integer overflows when sk->sk_rcvbuf is close to INT_MAX Kuniyuki Iwashima
2025-03-23 23:09 ` [PATCH v1 net 1/3] udp: Fix multiple wraparounds of sk->sk_rmem_alloc Kuniyuki Iwashima
2025-03-24 10:01 ` Eric Dumazet
2025-03-24 18:00 ` Kuniyuki Iwashima
2025-03-24 14:59 ` Willem de Bruijn
2025-03-24 18:10 ` Kuniyuki Iwashima
2025-03-24 19:44 ` Willem de Bruijn
2025-03-24 20:46 ` Kuniyuki Iwashima
2025-03-25 14:18 ` Willem de Bruijn
2025-03-25 17:53 ` Kuniyuki Iwashima
2025-03-23 23:09 ` [PATCH v1 net 2/3] udp: Fix memory accounting leak Kuniyuki Iwashima
2025-03-23 23:09 ` [PATCH v1 net 3/3] selftest: net: Check wraparounds for sk->sk_rmem_alloc Kuniyuki Iwashima
2025-03-24 15:58 ` Willem de Bruijn
2025-03-24 18:25 ` Kuniyuki Iwashima
2025-03-24 19:31 ` Willem de Bruijn [this message]
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=67e1b2fe98de0_35010c2946f@willemb.c.googlers.com.notmuch \
--to=willemdebruijn.kernel@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=kuniyu@amazon.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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