lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <89d843e16bd34e760a7ade6f14e46228f1bf56e8.camel@kernel.org>
Date: Thu, 27 Feb 2025 17:04:35 +0800
From: Geliang Tang <geliang@...nel.org>
To: Eric Dumazet <edumazet@...gle.com>
Cc: Kuniyuki Iwashima <kuniyu@...zon.com>, Paolo Abeni <pabeni@...hat.com>, 
 Willem de Bruijn <willemb@...gle.com>, "David S. Miller"
 <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,  Simon Horman
 <horms@...nel.org>, Neal Cardwell <ncardwell@...gle.com>, David Ahern
 <dsahern@...nel.org>,  Matthieu Baerts <matttbe@...nel.org>, Mat Martineau
 <martineau@...nel.org>, Marcelo Ricardo Leitner
 <marcelo.leitner@...il.com>, Xin Long <lucien.xin@...il.com>, Geliang Tang
 <tanggeliang@...inos.cn>, netdev@...r.kernel.org, mptcp@...ts.linux.dev, 
 linux-sctp@...r.kernel.org
Subject: Re: [PATCH net-next 4/4] net/tcp_ao: use sock_kmemdup for tcp_ao_key

On Thu, 2025-02-27 at 09:35 +0100, Eric Dumazet wrote:
> On Thu, Feb 27, 2025 at 9:24 AM Geliang Tang <geliang@...nel.org>
> wrote:
> > 
> > From: Geliang Tang <tanggeliang@...inos.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@...inos.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ