netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Cc: Boris Pismenny <borisp@nvidia.com>,
	John Fastabend <john.fastabend@gmail.com>,
	netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>, Jakub Kicinski <kuba@kernel.org>
Subject: Re: [PATCH net-next] net: tls: Pass union tls_crypto_context pointer to memzero_explicit
Date: Fri, 5 Jul 2024 16:21:38 +0100	[thread overview]
Message-ID: <20240705152138.GF1095183@kernel.org> (raw)
In-Reply-To: <bb960821-a67b-4d61-afeb-ead10ea2a4dc@intel.com>

On Fri, Jul 05, 2024 at 03:54:59PM +0200, Przemek Kitszel wrote:
> On 7/5/24 15:41, Simon Horman wrote:
> > Pass union tls_crypto_context pointer, rather than struct
> > tls_crypto_info pointer, to memzero_explicit().
> > 
> > The address of the pointer is the same before and after.
> > But the new construct means that the size of the dereferenced pointer type
> > matches the size being zeroed. Which aids static analysis.
> > 
> > As reported by Smatch:
> > 
> >    .../tls_main.c:842 do_tls_setsockopt_conf() error: memzero_explicit() 'crypto_info' too small (4 vs 56)
> > 
> > No functional change intended.
> > Compile tested only.
> > 
> > Signed-off-by: Simon Horman <horms@kernel.org>
> 
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> one small nitpick only

...

> > @@ -710,7 +713,7 @@ static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval,
> >   	return 0;
> >   err_crypto_info:
> > -	memzero_explicit(crypto_info, sizeof(union tls_crypto_context));
> > +	memzero_explicit(crypto_ctx, sizeof(union tls_crypto_context));
> 
> nit: That's a good fix to aid static analyzers, and reviewers.
> Now it's also easy to follow the standard style and pass
> sizeof(*crypto_ctx) instead of the type.

Thanks, that is a good suggestion.
I'll incorporate it in a v2.

      reply	other threads:[~2024-07-05 15:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-05 13:41 [PATCH net-next] net: tls: Pass union tls_crypto_context pointer to memzero_explicit Simon Horman
2024-07-05 13:54 ` Przemek Kitszel
2024-07-05 15:21   ` Simon Horman [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=20240705152138.GF1095183@kernel.org \
    --to=horms@kernel.org \
    --cc=borisp@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.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).