qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jeuk Kim <jeuk20.kim@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>,
	Minwoo Im <minwoo.im.dev@gmail.com>
Cc: Jeuk Kim <jeuk20.kim@samsung.com>,
	qemu-devel@nongnu.org, Minwoo Im <minwoo.im@samsung.com>
Subject: Re: [PATCH] hw/ufs: Fix potential bugs in MMIO read|write
Date: Mon, 24 Jun 2024 20:54:18 +0900	[thread overview]
Message-ID: <1cf11ba0-5b4c-4294-a34a-f238225dc261@gmail.com> (raw)
In-Reply-To: <CAFEAcA-NmcugQwa1u=Yt0GF4y1BAGUhi3ZnLhs6SPGP+s1sDLA@mail.gmail.com>


On 6/24/2024 7:27 PM, Peter Maydell wrote:
> On Sun, 23 Jun 2024 at 03:46, Minwoo Im <minwoo.im.dev@gmail.com> wrote:
>> This patch fixes two points reported in coverity scan report [1].  Check
>> the MMIO access address with (addr + size), not just with the start offset
>> addr to make sure that the requested memory access not to exceed the
>> actual register region.  We also updated (uint8_t *) to (uint32_t *) to
>> represent we are accessing the MMIO registers by dword-sized only.
>>
>> [1] https://lore.kernel.org/qemu-devel/CAFEAcA82L-WZnHMW0X+Dr40bHM-EVq2ZH4DG4pdqop4xxDP2Og@mail.gmail.com/
>>
>> Cc: Jeuk Kim <jeuk20.kim@gmail.com>
>> Reported-by: Peter Maydell <peter.maydell@linaro.org>
>> Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
>> ---
>>   hw/ufs/ufs.c | 31 ++++++++++++++++---------------
>>   1 file changed, 16 insertions(+), 15 deletions(-)
>>
>> diff --git a/hw/ufs/ufs.c b/hw/ufs/ufs.c
>> index 71a88d221ced..bf2ff02ac6e5 100644
>> --- a/hw/ufs/ufs.c
>> +++ b/hw/ufs/ufs.c
>> @@ -55,17 +55,18 @@ static inline uint64_t ufs_reg_size(UfsHc *u)
>>       return ufs_mcq_op_reg_addr(u, 0) + sizeof(u->mcq_op_reg);
>>   }
>>
>> -static inline bool ufs_is_mcq_reg(UfsHc *u, uint64_t addr)
>> +static inline bool ufs_is_mcq_reg(UfsHc *u, uint64_t addr, unsigned size)
>>   {
>>       uint64_t mcq_reg_addr = ufs_mcq_reg_addr(u, 0);
>> -    return addr >= mcq_reg_addr && addr < mcq_reg_addr + sizeof(u->mcq_reg);
>> +    return (addr >= mcq_reg_addr &&
>> +            addr + size <= mcq_reg_addr + sizeof(u->mcq_reg));
>>   }
>>
>> -static inline bool ufs_is_mcq_op_reg(UfsHc *u, uint64_t addr)
>> +static inline bool ufs_is_mcq_op_reg(UfsHc *u, uint64_t addr, unsigned size)
>>   {
>>       uint64_t mcq_op_reg_addr = ufs_mcq_op_reg_addr(u, 0);
>>       return (addr >= mcq_op_reg_addr &&
>> -            addr < mcq_op_reg_addr + sizeof(u->mcq_op_reg));
>> +            addr  + size <= mcq_op_reg_addr + sizeof(u->mcq_op_reg));
> Stray extra space after "addr".

Thank you for your comment.

I'll fix it when I send the pull request.

>
> Otherwise
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>
> thanks
> -- PMM


      reply	other threads:[~2024-06-24 11:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-23  2:45 [PATCH] hw/ufs: Fix potential bugs in MMIO read|write Minwoo Im
2024-06-24 10:14 ` Jeuk Kim
2024-06-24 10:27 ` Peter Maydell
2024-06-24 11:54   ` Jeuk Kim [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=1cf11ba0-5b4c-4294-a34a-f238225dc261@gmail.com \
    --to=jeuk20.kim@gmail.com \
    --cc=jeuk20.kim@samsung.com \
    --cc=minwoo.im.dev@gmail.com \
    --cc=minwoo.im@samsung.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).