mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Jungseung Lee <js07.lee@gmail.com>
Cc: "Shailendra Verma" <shailendra.v@samung.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Riley Andrews" <riandrews@android.com>,
	"Laura Abbott" <lauraa@codeaurora.org>,
	"Shailendra Verma" <shailendra.capricorn@gmail.com>,
	"Dan Carpenter" <dan.carpenter@oracle.com>,
	"Mitchel Humpherys" <mitchelh@codeaurora.org>,
	"Sumit Semwal" <sumit.semwal@linaro.org>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	"Gioh Kim" <gioh.kim@lge.com>,
	"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
	"Shawn Lin" <shawn.lin@rock-chips.com>,
	"Markus Elfring" <elfring@users.sourceforge.net>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	devel@driverdev.osuosl.org,
	"Ravikant Bijendra Sharma" <ravikant.s2@samsung.com>,
	"Shailendra Verma" <shailendra.v@samsung.com>,
	linux-kernel@vger.kernel.org, vidushi.koul@samsung.com,
	hillf.zj@alibaba-inc.com
Subject: Re: [PATCH] arch:arm:mm:Correction in the boundary check for module end address.
Date: Mon, 9 Nov 2015 16:01:37 +0000	[thread overview]
Message-ID: <20151109160137.GA8644@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <CAPP0e=POFR3BmH0jZvtcaWLM_zfLHG1eUcpkLX7dchrZxLigNA@mail.gmail.com>

On Tue, Nov 10, 2015 at 12:35:50AM +0900, Jungseung Lee wrote:
> Hi,
> 
> 2015-11-09 16:57 GMT+09:00 Shailendra Verma <shailendra.v@samung.com>:
> > From: Shailendra Verma <Shailendra.v@samsung.com>
> >
> > The module end boundary check is not proper.The out of bound value
> > of module end can produce undesired results.
> >
> > Signed-off-by: Shailendra Verma <Shailendra.v@samsung.com>
> > Reviewed-by: Ravikant Bijendra Sharma <ravikant.s2@samsung.com>
> > ---
> >  linux-4.3-rc6/arch/arm/mm/pageattr.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/linux-4.3-rc6/arch/arm/mm/pageattr.c b/linux-4.3-rc6/arch/arm/mm/pageattr.c
> > index cf30daf..be7fe4b 100644
> > --- a/linux-4.3-rc6/arch/arm/mm/pageattr.c
> > +++ b/linux-4.3-rc6/arch/arm/mm/pageattr.c
> > @@ -52,7 +52,7 @@ static int change_memory_common(unsigned long addr, int numpages,
> >         if (start < MODULES_VADDR || start >= MODULES_END)
> >                 return -EINVAL;
> >
> > -       if (end < MODULES_VADDR || start >= MODULES_END)
> > +       if (end < MODULES_VADDR || end >= MODULES_END)
> >                 return -EINVAL;
> >
> >         data.set_mask = set_mask;
> > --
> > 1.7.9.5
> >
> Same patch with proper format is already submitted by Hillf.
> https://lkml.org/lkml/2015/5/3/202

What happened to that patch?  It should at least have had a:

Fixes: f2ca09f381a5 ("ARM: 8311/1: Don't use is_module_addr in setting page attributes")

tag on it, and it needs to find its way into the patch system.  As
no one has reported a crash (I don't think it's crash-causing, but is
merely a correctness issue) I don't see any reason to backport it to
stable trees.

Other changes are needed here as well - the original commit creating
this contains:

+       if (!IS_ALIGNED(addr, PAGE_SIZE)) {
+               start &= PAGE_MASK;
+               end = start + size;
+               WARN_ON_ONCE(1);
+       }

which is truely amazing.  Fine, it may not be intended to work with
non-aligned addresses, but if we're going to round the start down,
then rounding the end down as well like that is also buggy.

	unsigned long start = addr;
	unsigned long size = PAGE_SIZE * numpages;
	unsigned long end = start + size;

	if (WARN_ON_ONCE(!IS_ALIGNED(addr, PAGE_SIZE)) {
		start &= PAGE_MASK;
		end = PAGE_ALIGN(end);
	}

would be much better - this will round 'end' up, so we encompass the
entire requested region.

-- 
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

  reply	other threads:[~2015-11-09 16:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-09  7:57 Shailendra Verma
2015-11-09 15:35 ` Jungseung Lee
2015-11-09 16:01   ` Russell King - ARM Linux [this message]
2015-11-10  2:50     ` Hillf Danton

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=20151109160137.GA8644@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=arve@android.com \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=elfring@users.sourceforge.net \
    --cc=gioh.kim@lge.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hillf.zj@alibaba-inc.com \
    --cc=js07.lee@gmail.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=lauraa@codeaurora.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=mitchelh@codeaurora.org \
    --cc=ravikant.s2@samsung.com \
    --cc=riandrews@android.com \
    --cc=shailendra.capricorn@gmail.com \
    --cc=shailendra.v@samsung.com \
    --cc=shailendra.v@samung.com \
    --cc=shawn.lin@rock-chips.com \
    --cc=sumit.semwal@linaro.org \
    --cc=vidushi.koul@samsung.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

all inboxes | Powered by JetHome®