linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Thierry Reding <treding@nvidia.com>,
	Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH] asm/sections: fix memory object end check
Date: Tue, 21 Dec 2021 09:56:17 +0000	[thread overview]
Message-ID: <YcGkwf0WSmfmOQXB@shell.armlinux.org.uk> (raw)
In-Reply-To: <20211221070624.1541842-1-agordeev@linux.ibm.com>

On Tue, Dec 21, 2021 at 08:06:24AM +0100, Alexander Gordeev wrote:
> Function memory_contains() checks whether a memory object is
> entirely contained within a memory region. The condition that
> checks the upper bound of the object against the upper bound
> of the region is inclusive. That does not correspond to the
> similar checks in memory_intersects() friend function, nor
> to the actual regions memory_contains() is called against.
> 
> In particular, __init_end address assumed do not belong to
> the init section itself. Similarly, on ARM __idmap_text_end
> and __entry_text_end are affected.

__init_end is exclusive as are the other symbols you mention here.
They point at the byte immediately following the area.

When testing an virt + size, the resulting address of "virt + size" is
always exclusive - this also points at the byte immediately following
the range of addresses. The preceeding byte is part of the object.

For example, if size is one, then we have a single byte, which is at
address "virt". "virt + 1" is not part of the object. Therefore, if
size is 1MiB, then "virt + 1048576" is similarly not part of the
object.

Hence, we _do_ want to test address + size <= end.

This code appears to me to be correct, and this patch _introduces_ a
bug.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      reply	other threads:[~2021-12-21  9:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-21  7:06 [PATCH] asm/sections: fix memory object end check Alexander Gordeev
2021-12-21  9:56 ` Russell King (Oracle) [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=YcGkwf0WSmfmOQXB@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=agordeev@linux.ibm.com \
    --cc=arnd@arndb.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=treding@nvidia.com \
    /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).