From: Jiri Slaby <jirislaby@kernel.org>
To: Alexander Bulekov <alxndr@bu.edu>, Chris Friedt <chrisfriedt@gmail.com>
Cc: qemu-devel@nongnu.org, cfriedt@meta.com
Subject: Re: [v2] hw: misc: edu: fix 2 off-by-one errors
Date: Tue, 18 Oct 2022 08:27:18 +0200 [thread overview]
Message-ID: <0a233177-e61a-05ab-7631-57fa75d15c78@kernel.org> (raw)
In-Reply-To: <20221017134425.jbqvtccg5w4yej5g@mozz.bu.edu>
On 17. 10. 22, 15:44, Alexander Bulekov wrote:
> On 221015 1710, Chris Friedt wrote:
>> From: Christopher Friedt <cfriedt@meta.com>
>>
>> In the case that size1 was zero, because of the explicit
>> 'end1 > addr' check, the range check would fail and the error
>> message would read as shown below. The correct comparison
>> is 'end1 >= addr' (or 'addr <= end1').
>>
>> EDU: DMA range 0x40000-0x3ffff out of bounds (0x40000-0x40fff)!
>>
>> At the opposite end, in the case that size1 was 4096, within()
>> would fail because of the non-inclusive check 'end1 < end2',
>> which should have been 'end1 <= end2'. The error message would
>> previously say
>>
>> EDU: DMA range 0x40000-0x40fff out of bounds (0x40000-0x40fff)!
>>
>> This change
>> 1. renames local variables to be more less ambiguous
>> 2. fixes the two off-by-one errors described above.
>>
>> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1254
>>
>> Signed-off-by: Christopher Friedt <cfriedt@meta.com>
>
> Reviewed-by: Alexander Bulekov <alxndr@bu.edu>
>
> As a side-note, seems strange that edu_check_range will abort the entire
> VM if the check fails, rather than handling the error more elegantly.
> Maybe that's useful for students developing kernel drivers against the
> device.
Yes, that was exactly the intention. First, as a punishment as they do
something really wrong. Second, so they notice -- writing something
wrong to a register of a real HW often freezes a machine too. Especially
when misprogramming a DMA controller.
OTOH, this sucks too. Ext4 (and other FS too) is fine, they don't lose
data. However they need to freshly boot, repair FS and investigate/think
a lot. This trial and run (and crash) takes several loops for some.
So I am for softening it a bit. But they still should be noticed in some
obvious way.
thanks,
--
js
suse labs
prev parent reply other threads:[~2022-10-18 6:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-15 21:10 [v2] hw: misc: edu: fix 2 off-by-one errors Chris Friedt
2022-10-17 6:22 ` Jiri Slaby
2022-10-17 16:36 ` Christopher Friedt
2022-11-01 18:59 ` Christopher Friedt
2022-10-17 13:44 ` Alexander Bulekov
2022-10-17 14:13 ` Peter Maydell
2022-10-17 17:21 ` Alex Bennée
2022-10-17 22:05 ` Chris Friedt
2022-10-18 6:11 ` Alex Bennée
2022-10-18 6:30 ` Jiri Slaby
2022-10-18 9:18 ` Alex Bennée
2022-10-18 9:30 ` Peter Maydell
2022-10-18 12:11 ` Alex Bennée
2022-10-18 6:27 ` Jiri Slaby [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=0a233177-e61a-05ab-7631-57fa75d15c78@kernel.org \
--to=jirislaby@kernel.org \
--cc=alxndr@bu.edu \
--cc=cfriedt@meta.com \
--cc=chrisfriedt@gmail.com \
--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 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.