From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Sergey Shtylyov <s.shtylyov@omp.ru>, linux-ide@vger.kernel.org
Subject: Re: [PATCH v2 2/2] ata: libata-core: fix sloppy parameter type in ata_exec_internal[_sg]()
Date: Sat, 18 Jun 2022 15:45:42 +0900 [thread overview]
Message-ID: <a2d8df09-2ecf-baa5-d8ee-4651f5a612f1@opensource.wdc.com> (raw)
In-Reply-To: <c2aac3d9-d1d9-eb87-2644-462f30902352@omp.ru>
On 6/18/22 02:27, Sergey Shtylyov wrote:
> Hello!
>
> On 6/17/22 10:44 AM, Damien Le Moal wrote:
>
>>> Make the 'timeout' parameter to ata_exec_internal_sg() *unsigned int* as
>>> msecs_to_jiffies() that it calls takes just *unsigned int* for the time in
>>> milliseconds. Then follow the suit with ata_exec_internal(), its only
>>> caller; also fix up ata_dev_set_feature(), the only ata_exec_internal()'s
>>> caller that explicitly passes *unsigned long* variable for timeout...
>>
>> Checking this, struct ata_eh_cmd_timeout_ent uses an unsigned long timeout
>> and ata_internal_cmd_timeout() returns an unsigned long which is stored
>> into the unsigned int timeout variable.
>
> I know. All timeouts stored in those tables fit into *unsigned int* (except
> the last ones which get truncated from ULONG_MAX to UINT_MAX anyways).
> Note that *unsigned long* has always been silently truncated to *unsigned int*
> when calling msecs_to_jiffies() in ata_exec_internal_sg(); nothing changes with
> my patch, it just gets truncated a bit earlier...
>
>> So it may be good to add another
>> prep patch before this one to cleanup the auto_timeout stuff (struct
>> ata_eh_cmd_timeout_ent and ata_internal_cmd_timeout()).
>
> It shouldn't matter whether we do it before or after this patch, due to
> truncation which happens even now (I have such a patch, but no description
> yet). I was planning to address that as a part of the large patch series,
> most probably next week (and I wrote about that in the cover letter)...
>
>> Hmm ? Thoughts ?
>
> Was I clear enough? :-)
>
>>> Found by Linux Verification Center (linuxtesting.org) with the SVACE static
>>> analysis tool.
>
> I wanted to fix SVACE's reports 1st, then the rest of the sloppy timeout
> typing...
Fine. But in the spirit of fixing everything with these types, please add
a patch to also convert the timeout tables to unsigned int. It is never a
good idea to have code silently truncate long to int as that can be a pain
to debug. So let's go all the way and fix this.
If you cannot do the additional patch, I will do it.
>
>>>
>>> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> [...]
>
> MBR, Sergey
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2022-06-18 6:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-15 19:38 [PATCH v2 0/2] Fix sloppy 'timeout' parameter type in libata-core.c Sergey Shtylyov
2022-06-15 19:38 ` [PATCH v2 1/2] ata: libata-core: make ata_exec_internal_sg() *static* Sergey Shtylyov
2022-06-17 7:48 ` Damien Le Moal
2022-06-15 19:38 ` [PATCH v2 2/2] ata: libata-core: fix sloppy parameter type in ata_exec_internal[_sg]() Sergey Shtylyov
2022-06-17 7:44 ` Damien Le Moal
2022-06-17 17:27 ` Sergey Shtylyov
2022-06-18 6:45 ` Damien Le Moal [this message]
2022-06-18 19:49 ` Sergey Shtylyov
2022-06-19 23:23 ` Damien Le Moal
2022-06-15 19:49 ` [PATCH v2 0/2] Fix sloppy 'timeout' parameter type in libata-core.c Sergey Shtylyov
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=a2d8df09-2ecf-baa5-d8ee-4651f5a612f1@opensource.wdc.com \
--to=damien.lemoal@opensource.wdc.com \
--cc=linux-ide@vger.kernel.org \
--cc=s.shtylyov@omp.ru \
/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