From: Steen Hegelund <steen.hegelund@microchip.com>
To: Dmitry Safonov <dima@arista.com>
Cc: David Ahern <dsahern@kernel.org>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
<linux-kernel@vger.kernel.org>,
"Andy Lutomirski" <luto@amacapital.net>,
Ard Biesheuvel <ardb@kernel.org>,
"Bob Gilligan" <gilligan@arista.com>,
Dan Carpenter <error27@gmail.com>,
"David Laight" <David.Laight@aculab.com>,
Dmitry Safonov <0x7f454c46@gmail.com>,
Donald Cassidy <dcassidy@redhat.com>,
Eric Biggers <ebiggers@kernel.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Francesco Ruggeri <fruggeri05@gmail.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"Hideaki YOSHIFUJI" <yoshfuji@linux-ipv6.org>,
Ivan Delalande <colona@arista.com>,
Leonard Crestez <cdleonard@gmail.com>,
Salam Noureddine <noureddine@arista.com>,
<netdev@vger.kernel.org>
Subject: Re: [PATCH v7 01/22] net/tcp: Prepare tcp_md5sig_pool for TCP-AO
Date: Fri, 16 Jun 2023 09:00:36 +0200 [thread overview]
Message-ID: <3225c5197b80960a66c89214b4823080388963d2.camel@microchip.com> (raw)
In-Reply-To: <21845b01-a915-d80a-8b87-85c6987c7691@arista.com>
Hi Dmitry,
On Thu, 2023-06-15 at 17:44 +0100, Dmitry Safonov wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the
> content is safe
>
> Hi Steen,
>
> On 6/15/23 11:45, Steen Hegelund wrote:
> > Hi Dmitry,
> >
> > On Thu, 2023-06-15 at 00:09 +0100, Dmitry Safonov wrote:
> [..]
> > > +/**
> > > + * tcp_sigpool_alloc_ahash - allocates pool for ahash requests
> > > + * @alg: name of async hash algorithm
> > > + * @scratch_size: reserve a tcp_sigpool::scratch buffer of this size
> > > + */
> > > +int tcp_sigpool_alloc_ahash(const char *alg, size_t scratch_size)
> > > +{
> > > + int i, ret;
> > > +
> > > + /* slow-path */
> > > + mutex_lock(&cpool_mutex);
> > > + ret = sigpool_reserve_scratch(scratch_size);
> > > + if (ret)
> > > + goto out;
> > > + for (i = 0; i < cpool_populated; i++) {
> > > + if (!cpool[i].alg)
> > > + continue;
> > > + if (strcmp(cpool[i].alg, alg))
> > > + continue;
> > > +
> > > + if (kref_read(&cpool[i].kref) > 0)
> > > + kref_get(&cpool[i].kref);
> > > + else
> > > + kref_init(&cpool[i].kref);
> > > + ret = i;
> > > + goto out;
> > > + }
> >
> > Here it looks to me like you will never get to this part of the code since
> > you
> > always end up going to the out label in the previous loop.
>
> Well, not exactly: this part is looking if the crypto algorithm is
> already in this pool, so that it can increment refcounter rather than
> initialize a new tfm. In case strcmp(cpool[i].alg, alg) fails, this loop
> will never goto out.
Ah, right, you never find any algo and then get out at the end of the list.
>
> I.e., you issued previously setsockopt()s for TCP-MD5 and TCP-AO with
> HMAC-SHA1, so in this pool there'll be two algorithms: "md5" and
> "hmac(sha1)". Now if you want to use TCP-AO with "cmac(aes128)" or
> "hmac(sha256)", you won't find them in the pool yet.
>
> >
> > > +
> > > + for (i = 0; i < cpool_populated; i++) {
> > > + if (!cpool[i].alg)
> > > + break;
> > > + }
> > > + if (i >= CPOOL_SIZE) {
> > > + ret = -ENOSPC;
> > > + goto out;
> > > + }
> > > +
> > > + ret = __cpool_alloc_ahash(&cpool[i], alg);
> > > + if (!ret) {
> > > + ret = i;
> > > + if (i == cpool_populated)
> > > + cpool_populated++;
> > > + }
> > > +out:
> > > + mutex_unlock(&cpool_mutex);
> > > + return ret;
> > > +}
> > > +EXPORT_SYMBOL_GPL(tcp_sigpool_alloc_ahash);
> > > +
> >
> > ... snip ...
> >
> >
> > > clear_hash:
> > > - tcp_put_md5sig_pool();
> > > -clear_hash_noput:
> > > + tcp_sigpool_end(&hp);
> > > +clear_hash_nostart:
> > > memset(md5_hash, 0, 16);
> > > return 1;
> > > }
> Thanks,
> Dmitry
>
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
BR
Steen
next prev parent reply other threads:[~2023-06-16 7:00 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-14 23:09 [PATCH v7 00/22] net/tcp: Add TCP-AO support Dmitry Safonov
2023-06-14 23:09 ` [PATCH v7 01/22] net/tcp: Prepare tcp_md5sig_pool for TCP-AO Dmitry Safonov
2023-06-15 10:45 ` Steen Hegelund
2023-06-15 16:44 ` Dmitry Safonov
2023-06-16 7:00 ` Steen Hegelund [this message]
2023-06-14 23:09 ` [PATCH v7 02/22] net/tcp: Add TCP-AO config and structures Dmitry Safonov
2023-06-14 23:09 ` [PATCH v7 03/22] net/tcp: Introduce TCP_AO setsockopt()s Dmitry Safonov
2023-06-14 23:09 ` [PATCH v7 04/22] net/tcp: Prevent TCP-MD5 with TCP-AO being set Dmitry Safonov
2023-06-18 17:50 ` David Ahern
2023-06-19 16:31 ` Dmitry Safonov
2023-06-19 16:41 ` Dmitry Safonov
2023-06-19 16:59 ` Dmitry Safonov
2023-06-14 23:09 ` [PATCH v7 05/22] net/tcp: Calculate TCP-AO traffic keys Dmitry Safonov
2023-06-14 23:09 ` [PATCH v7 06/22] net/tcp: Add TCP-AO sign to outgoing packets Dmitry Safonov
2023-06-14 23:09 ` [PATCH v7 07/22] net/tcp: Add tcp_parse_auth_options() Dmitry Safonov
2023-06-14 23:09 ` [PATCH v7 08/22] net/tcp: Add AO sign to RST packets Dmitry Safonov
2023-06-15 1:22 ` kernel test robot
2023-06-15 1:23 ` kernel test robot
2023-06-15 11:47 ` kernel test robot
2023-06-14 23:09 ` [PATCH v7 09/22] net/tcp: Add TCP-AO sign to twsk Dmitry Safonov
2023-06-14 23:09 ` [PATCH v7 10/22] net/tcp: Wire TCP-AO to request sockets Dmitry Safonov
2023-06-14 23:09 ` [PATCH v7 11/22] net/tcp: Sign SYN-ACK segments with TCP-AO Dmitry Safonov
2023-06-14 23:09 ` [PATCH v7 12/22] net/tcp: Verify inbound TCP-AO signed segments Dmitry Safonov
2023-06-14 23:09 ` [PATCH v7 13/22] net/tcp: Add TCP-AO segments counters Dmitry Safonov
2023-06-14 23:09 ` [PATCH v7 14/22] net/tcp: Add TCP-AO SNE support Dmitry Safonov
2023-06-14 23:09 ` [PATCH v7 15/22] net/tcp: Add tcp_hash_fail() ratelimited logs Dmitry Safonov
2023-06-14 23:09 ` [PATCH v7 16/22] net/tcp: Ignore specific ICMPs for TCP-AO connections Dmitry Safonov
2023-06-14 23:09 ` [PATCH v7 17/22] net/tcp: Add option for TCP-AO to (not) hash header Dmitry Safonov
2023-06-14 23:09 ` [PATCH v7 18/22] net/tcp: Add TCP-AO getsockopt()s Dmitry Safonov
2023-06-14 23:09 ` [PATCH v7 19/22] net/tcp: Allow asynchronous delete for TCP-AO keys (MKTs) Dmitry Safonov
2023-06-14 23:09 ` [PATCH v7 20/22] net/tcp: Add static_key for TCP-AO Dmitry Safonov
2023-06-14 23:09 ` [PATCH v7 21/22] net/tcp: Wire up l3index to TCP-AO Dmitry Safonov
2023-06-14 23:09 ` [PATCH v7 22/22] net/tcp: Add TCP_AO_REPAIR Dmitry Safonov
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=3225c5197b80960a66c89214b4823080388963d2.camel@microchip.com \
--to=steen.hegelund@microchip.com \
--cc=0x7f454c46@gmail.com \
--cc=David.Laight@aculab.com \
--cc=ardb@kernel.org \
--cc=cdleonard@gmail.com \
--cc=colona@arista.com \
--cc=davem@davemloft.net \
--cc=dcassidy@redhat.com \
--cc=dima@arista.com \
--cc=dsahern@kernel.org \
--cc=ebiederm@xmission.com \
--cc=ebiggers@kernel.org \
--cc=edumazet@google.com \
--cc=error27@gmail.com \
--cc=fruggeri05@gmail.com \
--cc=gilligan@arista.com \
--cc=herbert@gondor.apana.org.au \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=netdev@vger.kernel.org \
--cc=noureddine@arista.com \
--cc=pabeni@redhat.com \
--cc=yoshfuji@linux-ipv6.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 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).