All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Cc: Thorsten Blum <thorsten.blum@linux.dev>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	Jack Xu <jack.xu@intel.com>,
	Suman Kumar Chakraborty <suman.kumar.chakraborty@intel.com>,
	Qianfeng Rong <rongqianfeng@vivo.com>,
	qat-linux@intel.com, linux-crypto@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] crypto: qat - use strscpy_pad to simplify buffer initialization
Date: Fri, 24 Oct 2025 12:49:40 +0300	[thread overview]
Message-ID: <aPtLtEJJ3jV12FNJ@smile.fi.intel.com> (raw)
In-Reply-To: <aPs9w2su33uXfD09@gcabiddu-mobl.ger.corp.intel.com>

On Fri, Oct 24, 2025 at 09:50:11AM +0100, Giovanni Cabiddu wrote:
> On Thu, Oct 23, 2025 at 09:44:01PM +0300, Andy Shevchenko wrote:
> > On Thu, Oct 23, 2025 at 05:35:00PM +0200, Thorsten Blum wrote:
> > > On 22. Oct 2025, at 20:17, Andy Shevchenko wrote:
> > > > On Wed, Oct 22, 2025 at 02:36:19PM +0200, Thorsten Blum wrote:

...

> > > How about this?
> > 
> > LGTM, and that's what I had in mind, but please double check the behaviour of
> > kstrtox() on an empty strings.
> 
> LGTM as well.
> 
> I checked the behaviour of kstrtoul() when given an empty string. It
> returns -EINVAL (-22). The result variable (the third parameter) is only
> modified if the conversion is succesful.

Thanks for confirming!

> Anyway, the caller will not provide a NULL string to this function [1].
> 
> > > +	unsigned long long ae;
> > > +	char *end;
> > >  
> > > +	ae = simple_strtoull(str, &end, 10);
> > > +	if (ae > UINT_MAX || str == end || (end - str) > 20)
> > 
> > I would go with >= 20, the 64-bit value is approx. 1 * 10^19.
> 
> Just an insight into the type of strings being parsed here. If they are
> well-formed, the format looks like:
> 
>     <AE_NUMBER>!<...>
> 
> Example:
> 
>     11!l0000!lm_thread_ctrl_struct_base
> 
> This function just extract the first number. Currently, that is 2 digits [2],
> and I believe it is unlikely to exceed 3 in future gens.

Yep, but it is better to make code more robust (and esp. in case somebody
copies'n'pastes to somewhere else).

> [1] https://elixir.bootlin.com/linux/v6.17.4/source/drivers/crypto/intel/qat/qat_common/qat_uclo.c#L237
> [2] https://elixir.bootlin.com/linux/v6.17.4/source/drivers/crypto/intel/qat/qat_common/icp_qat_uclo.h#L11

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2025-10-24  9:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-22 12:36 [PATCH] crypto: qat - use strscpy_pad to simplify buffer initialization Thorsten Blum
2025-10-22 18:17 ` Andy Shevchenko
2025-10-22 18:29   ` Andy Shevchenko
2025-10-23 15:35   ` Thorsten Blum
2025-10-23 18:44     ` Andy Shevchenko
2025-10-24  8:50       ` Giovanni Cabiddu
2025-10-24  9:49         ` Andy Shevchenko [this message]
2025-10-24 18:47       ` Thorsten Blum
2025-10-27  8:19         ` Andy Shevchenko
2025-10-27  8:43           ` Thorsten Blum

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=aPtLtEJJ3jV12FNJ@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=giovanni.cabiddu@intel.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=jack.xu@intel.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qat-linux@intel.com \
    --cc=rongqianfeng@vivo.com \
    --cc=suman.kumar.chakraborty@intel.com \
    --cc=thorsten.blum@linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.