mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jürgen Groß" <jgross@suse.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: linux-hardening@vger.kernel.org, xen-devel@lists.xenproject.org,
	linux-kernel@vger.kernel.org,
	Stefano Stabellini <sstabellini@kernel.org>,
	Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>,
	Jason Andryuk <jason.andryuk@amd.com>,
	"Dr. David Alan Gilbert" <linux@treblig.org>,
	Thorsten Blum <thorsten.blum@linux.dev>
Subject: Re: [PATCH] drivers/xen/xenbus: Replace deprecated strcpy in xenbus_transaction_end
Date: Mon, 13 Oct 2025 11:24:15 +0200	[thread overview]
Message-ID: <2cce7bee-af02-4850-b1a8-b7f2cf3f1efb@suse.com> (raw)
In-Reply-To: <13cbd826-540e-4352-8e0d-ae0c9fbd2faa@suse.com>


[-- Attachment #1.1.1: Type: text/plain, Size: 2460 bytes --]

On 13.10.25 10:22, Jan Beulich wrote:
> On 13.10.2025 09:36, Jürgen Groß wrote:
>> On 13.10.25 08:59, Jan Beulich wrote:
>>> On 12.10.2025 21:55, Thorsten Blum wrote:
>>>> --- a/drivers/xen/xenbus/xenbus_xs.c
>>>> +++ b/drivers/xen/xenbus/xenbus_xs.c
>>>> @@ -546,16 +546,13 @@ int xenbus_transaction_start(struct xenbus_transaction *t)
>>>>    EXPORT_SYMBOL_GPL(xenbus_transaction_start);
>>>>    
>>>>    /* End a transaction.
>>>> - * If abandon is true, transaction is discarded instead of committed.
>>>> + * If abort is true, transaction is discarded instead of committed.
>>>>     */
>>>> -int xenbus_transaction_end(struct xenbus_transaction t, int abort)
>>>> +int xenbus_transaction_end(struct xenbus_transaction t, bool abort)
>>>>    {
>>>>    	char abortstr[2];
>>>>    
>>>> -	if (abort)
>>>> -		strcpy(abortstr, "F");
>>>> -	else
>>>> -		strcpy(abortstr, "T");
>>>
>>> While at least in principle a compiler might be able to transform this into
>>> code not using any library function at all, ...
>>>
>>>> +	strscpy(abortstr, abort ? "F" : "T");
>>>
>>> ... the use of a n on-standard function (without equivalent compiler builtin)
>>> doesn't permit this. IOW why not simply switch to e.g.
>>>
>>>       char abortstr[2] = { [0] = abort ? 'F' : 'T' };
>>
>> I would even go further and drop abortstr[] completely:
>>
>> diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
>> index 528682bf0c7f..c891af7165f5 100644
>> --- a/drivers/xen/xenbus/xenbus_xs.c
>> +++ b/drivers/xen/xenbus/xenbus_xs.c
>> @@ -550,14 +550,8 @@ EXPORT_SYMBOL_GPL(xenbus_transaction_start);
>>     */
>>    int xenbus_transaction_end(struct xenbus_transaction t, int abort)
>>    {
>> -       char abortstr[2];
>> -
>> -       if (abort)
>> -               strcpy(abortstr, "F");
>> -       else
>> -               strcpy(abortstr, "T");
>> -
>> -       return xs_error(xs_single(t, XS_TRANSACTION_END, abortstr, NULL));
>> +       return xs_error(xs_single(t, XS_TRANSACTION_END, abort ? "F" : "T",
>> +                       NULL));
>>    }
>>    EXPORT_SYMBOL_GPL(xenbus_transaction_end);
> 
> Hmm, which xs_single() indeed takes a const char *, it then casts away const-
> ness before handing to xs_talkv().

Yes, the cast is needed as xs_talkv() can handle reads and writes. No problem in
this case, as the string is only read by xs_talkv() (write type operation).


Juergen

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

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

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-12 19:55 Thorsten Blum
2025-10-13  6:59 ` Jan Beulich
2025-10-13  7:36   ` Jürgen Groß
2025-10-13  8:22     ` Jan Beulich
2025-10-13  9:24       ` Jürgen Groß [this message]
2025-10-13 11:23         ` 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=2cce7bee-af02-4850-b1a8-b7f2cf3f1efb@suse.com \
    --to=jgross@suse.com \
    --cc=jason.andryuk@amd.com \
    --cc=jbeulich@suse.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@treblig.org \
    --cc=oleksandr_tyshchenko@epam.com \
    --cc=sstabellini@kernel.org \
    --cc=thorsten.blum@linux.dev \
    --cc=xen-devel@lists.xenproject.org \
    /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

all inboxes | Powered by JetHome®