From: Chuck Lever III <chuck.lever@oracle.com>
To: Hannes Reinecke <hare@suse.de>
Cc: Chuck Lever <cel@kernel.org>,
"davem@davemloft.net" <davem@davemloft.net>,
"edumazet@google.com" <edumazet@google.com>,
"kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"kernel-tls-handshake@lists.linux.dev"
<kernel-tls-handshake@lists.linux.dev>
Subject: Re: [PATCH net-next v1 5/7] net/handshake: Add helpers for parsing incoming TLS Alerts
Date: Thu, 20 Jul 2023 14:22:27 +0000 [thread overview]
Message-ID: <3886979D-296F-4FC7-803C-C0BF61E2750D@oracle.com> (raw)
In-Reply-To: <497c5403-fdba-1f9d-5e7b-4aa32481413d@suse.de>
> On Jul 20, 2023, at 1:44 AM, Hannes Reinecke <hare@suse.de> wrote:
>
> On 7/19/23 15:36, Chuck Lever III wrote:
>>> On Jul 19, 2023, at 3:52 AM, Hannes Reinecke <hare@suse.de> wrote:
>>>
>>> On 7/18/23 21:00, Chuck Lever wrote:
>>>> From: Chuck Lever <chuck.lever@oracle.com>
>>>> Kernel TLS consumers can replace common TLS Alert parsing code with
>>>> these helpers.
>>>> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
>>>> ---
>>>> include/net/handshake.h | 4 ++++
>>>> net/handshake/alert.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
>>>> 2 files changed, 50 insertions(+)
>>>> diff --git a/include/net/handshake.h b/include/net/handshake.h
>>>> index bb88dfa6e3c9..d0fd6a3898c6 100644
>>>> --- a/include/net/handshake.h
>>>> +++ b/include/net/handshake.h
>>>> @@ -42,4 +42,8 @@ int tls_server_hello_psk(const struct tls_handshake_args *args, gfp_t flags);
>>>> bool tls_handshake_cancel(struct sock *sk);
>>>> void tls_handshake_close(struct socket *sock);
>>>> +u8 tls_record_type(const struct sock *sk, const struct cmsghdr *msg);
>>>> +bool tls_alert_recv(const struct sock *sk, const struct msghdr *msg,
>>>> + u8 *level, u8 *description);
>>>> +
>>>> #endif /* _NET_HANDSHAKE_H */
>>>> diff --git a/net/handshake/alert.c b/net/handshake/alert.c
>>>> index 999d3ffaf3e3..93e05d8d599c 100644
>>>> --- a/net/handshake/alert.c
>>>> +++ b/net/handshake/alert.c
>>>> @@ -60,3 +60,49 @@ int tls_alert_send(struct socket *sock, u8 level, u8 description)
>>>> ret = sock_sendmsg(sock, &msg);
>>>> return ret < 0 ? ret : 0;
>>>> }
>>>> +
>>>> +/**
>>>> + * tls_record_type - Look for TLS RECORD_TYPE information
>>>> + * @sk: socket (for IP address information)
>>>> + * @cmsg: incoming message to be parsed
>>>> + *
>>>> + * Returns zero or a TLS_RECORD_TYPE value.
>>>> + */
>>>> +u8 tls_record_type(const struct sock *sk, const struct cmsghdr *cmsg)
>>>> +{
>>>> + u8 record_type;
>>>> +
>>>> + if (cmsg->cmsg_level != SOL_TLS)
>>>> + return 0;
>>>> + if (cmsg->cmsg_type != TLS_GET_RECORD_TYPE)
>>>> + return 0;
>>>> +
>>>> + record_type = *((u8 *)CMSG_DATA(cmsg));
>>>> + return record_type;
>>>> +}
>>>> +EXPORT_SYMBOL(tls_record_type);
>>>> +
>>> tls_process_cmsg() does nearly the same thing; why didn't you update it to use your helper?
>> tls_process_cmsg() is looking for TLS_SET_RECORD_TYPE,
>> not TLS_GET_RECORD_TYPE. It looks different enough that
>> I didn't feel comfortable touching it.
> Argl. Totally forgot that we have TLS_GET_RECORD_TYPE and TLS_SET_RECORD_TYPE ...
> But to make it clear, shouldn't we rather name the function
> tls_get_record_type()
Renamed. Thanks for the review! I will post v2 next week, waiting
for more review comments.
--
Chuck Lever
next prev parent reply other threads:[~2023-07-20 14:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-18 18:58 [PATCH net-next v1 0/7] In-kernel support for the TLS Alert protocol Chuck Lever
2023-07-18 18:59 ` [PATCH net-next v1 1/7] net/tls: Move TLS protocol elements to a separate header Chuck Lever
2023-07-18 18:59 ` [PATCH net-next v1 2/7] net/tls: Add TLS Alert definitions Chuck Lever
2023-07-19 7:40 ` Hannes Reinecke
2023-07-18 19:00 ` [PATCH net-next v1 3/7] net/handshake: Add API for sending TLS Closure alerts Chuck Lever
2023-07-19 7:47 ` Hannes Reinecke
2023-07-19 13:24 ` Chuck Lever III
2023-07-18 19:00 ` [PATCH net-next v1 4/7] SUNRPC: Send TLS Closure alerts before closing a TCP socket Chuck Lever
2023-07-18 19:00 ` [PATCH net-next v1 5/7] net/handshake: Add helpers for parsing incoming TLS Alerts Chuck Lever
2023-07-19 7:52 ` Hannes Reinecke
2023-07-19 13:36 ` Chuck Lever III
2023-07-20 5:44 ` Hannes Reinecke
2023-07-20 14:22 ` Chuck Lever III [this message]
2023-07-18 19:01 ` [PATCH net-next v1 6/7] SUNRPC: Use new helpers to handle " Chuck Lever
2023-07-18 19:01 ` [PATCH net-next v1 7/7] net/handshake: Trace events for TLS Alert helpers Chuck Lever
2023-07-19 7:53 ` Hannes Reinecke
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=3886979D-296F-4FC7-803C-C0BF61E2750D@oracle.com \
--to=chuck.lever@oracle.com \
--cc=cel@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hare@suse.de \
--cc=kernel-tls-handshake@lists.linux.dev \
--cc=kuba@kernel.org \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).