From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1266A1EB5F3; Thu, 27 Feb 2025 09:06:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740647175; cv=none; b=ej8c+BB5QZ25V5JWS+tTemc/bHhy781h3jejSDJqFjiP3WLngqWZ1qk689EEFnxgnq26avNr77AAtB6jMDG5c1EQnClQgk4s/piz2JkKT74lDq6m66K3eW3ejz6F7wZ+PAS2c/AW8OMsNuDNO39q1qEvVFat3pZFvT3vcYBAJF8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740647175; c=relaxed/simple; bh=N1M+rRf2NUE4/xDm4cfzB4S+xLOeRa/qlHLE5rAdoGQ=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=BUn801RbioFSG6Eh6frH1HscBUZnG7wv4C0ZkrUifucATKdU8ScOo2JolLyQu0mnv/W7F7iRc92W7F/qruvECtnUqm25rpo2uFKnBVAcmKOsUmg8fElj3CLuqkfdS7VpiPrBOwK28GKct5KqmSmyOEmQryuWcVu9UqsegWnL6xw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WVx082+a; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WVx082+a" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06683C4CEDD; Thu, 27 Feb 2025 09:06:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740647174; bh=N1M+rRf2NUE4/xDm4cfzB4S+xLOeRa/qlHLE5rAdoGQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=WVx082+a/Iiau0I6vbuA3qUcYZM6r2OT/SsccLf/31pd/Afm6BVndj23L4TRxCg90 4n6pbSpVfcJuBANbftkZfMHZDiTmoGdI94TQhlDRM5UMgf99oUO6GDL0JYGvvf1Jun J4kQbP0P6VDvR5rH4BgFR5Mf477FjMUzOK3AefhCCHcpyyZb7buqS2nyd5sJxPh2up f0ng3SuchXUESroJwvAxluTB3GwdO8fP6jKrwLezJ9zCAsnIxLgMRZWysEq5EX5t+n 5n27nCDyKXpZIOruj1BnHgdfTui1xTfMFco6HWXvIj+75rrBGa5fB2f2xl/bj3/Ipa cJ4bdFET5YG0g== Message-ID: <89d843e16bd34e760a7ade6f14e46228f1bf56e8.camel@kernel.org> Subject: Re: [PATCH net-next 4/4] net/tcp_ao: use sock_kmemdup for tcp_ao_key From: Geliang Tang To: Eric Dumazet Cc: Kuniyuki Iwashima , Paolo Abeni , Willem de Bruijn , "David S. Miller" , Jakub Kicinski , Simon Horman , Neal Cardwell , David Ahern , Matthieu Baerts , Mat Martineau , Marcelo Ricardo Leitner , Xin Long , Geliang Tang , netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-sctp@vger.kernel.org Date: Thu, 27 Feb 2025 17:04:35 +0800 In-Reply-To: References: <38054b456a54cc5c7628c81a42816a770f0bff27.1740643844.git.tanggeliang@kylinos.cn> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.52.3-0ubuntu1 Precedence: bulk X-Mailing-List: linux-sctp@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Thu, 2025-02-27 at 09:35 +0100, Eric Dumazet wrote: > On Thu, Feb 27, 2025 at 9:24 AM Geliang Tang > wrote: > > > > From: Geliang Tang > > > > 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 > > --- > >  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