From: Geliang Tang <geliang@kernel.org>
To: Eric Dumazet <edumazet@google.com>
Cc: Kuniyuki Iwashima <kuniyu@amazon.com>,
Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Simon Horman <horms@kernel.org>,
Neal Cardwell <ncardwell@google.com>,
David Ahern <dsahern@kernel.org>,
Matthieu Baerts <matttbe@kernel.org>,
Mat Martineau <martineau@kernel.org>,
Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
Xin Long <lucien.xin@gmail.com>,
Geliang Tang <tanggeliang@kylinos.cn>,
netdev@vger.kernel.org, mptcp@lists.linux.dev,
linux-sctp@vger.kernel.org
Subject: Re: [PATCH net-next 4/4] net/tcp_ao: use sock_kmemdup for tcp_ao_key
Date: Thu, 27 Feb 2025 17:04:35 +0800 [thread overview]
Message-ID: <89d843e16bd34e760a7ade6f14e46228f1bf56e8.camel@kernel.org> (raw)
In-Reply-To: <CANn89i+ZLAPPKVCzAMrchJBvisiOsEZyVN-TqGUkEH8EFApbpQ@mail.gmail.com>
On Thu, 2025-02-27 at 09:35 +0100, Eric Dumazet wrote:
> On Thu, Feb 27, 2025 at 9:24 AM Geliang Tang <geliang@kernel.org>
> wrote:
> >
> > From: Geliang Tang <tanggeliang@kylinos.cn>
> >
> > Instead of using sock_kmalloc() to allocate a tcp_ao_key "new_key"
> > and
> > then immediately duplicate the input "key" to it in
> > tcp_ao_copy_key(),
> > the newly added sock_kmemdup() helper can be used to simplify the
> > code.
> >
> > Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> > ---
> > net/ipv4/tcp_ao.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/net/ipv4/tcp_ao.c b/net/ipv4/tcp_ao.c
> > index bbb8d5f0eae7..d21412d469cc 100644
> > --- a/net/ipv4/tcp_ao.c
> > +++ b/net/ipv4/tcp_ao.c
> > @@ -246,12 +246,11 @@ static struct tcp_ao_key
> > *tcp_ao_copy_key(struct sock *sk,
> > {
> > struct tcp_ao_key *new_key;
> >
> > - new_key = sock_kmalloc(sk, tcp_ao_sizeof_key(key),
> > + new_key = sock_kmemdup(sk, key, tcp_ao_sizeof_key(key),
> > GFP_ATOMIC);
> > if (!new_key)
> > return NULL;
> >
> > - *new_key = *key;
>
> Note that this only copies 'sizeof(struct tcp_ao_key)' bytes, which
> is
> smaller than tcp_ao_sizeof_key(key)
Yes, indeed. sock_kmemdup() shouldn't be used here then. I'll drop this
patch in v2.
Thanks,
-Geliang
prev parent reply other threads:[~2025-02-27 9:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-27 8:23 [PATCH net-next 0/4] add sock_kmemdup helper Geliang Tang
2025-02-27 8:23 ` [PATCH net-next 1/4] sock: " Geliang Tang
2025-02-27 8:45 ` Matthieu Baerts
2025-02-27 9:05 ` Geliang Tang
2025-02-27 8:23 ` [PATCH net-next 2/4] net: use sock_kmemdup for ip_options Geliang Tang
2025-02-27 8:23 ` [PATCH net-next 3/4] mptcp: use sock_kmemdup for address entry Geliang Tang
2025-02-27 8:23 ` [PATCH net-next 4/4] net/tcp_ao: use sock_kmemdup for tcp_ao_key Geliang Tang
2025-02-27 8:35 ` Eric Dumazet
2025-02-27 9:04 ` Geliang Tang [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=89d843e16bd34e760a7ade6f14e46228f1bf56e8.camel@kernel.org \
--to=geliang@kernel.org \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@amazon.com \
--cc=linux-sctp@vger.kernel.org \
--cc=lucien.xin@gmail.com \
--cc=marcelo.leitner@gmail.com \
--cc=martineau@kernel.org \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tanggeliang@kylinos.cn \
--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).