Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751691AbbKJCvV (ORCPT ); Mon, 9 Nov 2015 21:51:21 -0500 Received: from out4133-98.mail.aliyun.com ([42.120.133.98]:8370 "EHLO out4133-98.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751074AbbKJCvU (ORCPT ); Mon, 9 Nov 2015 21:51:20 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e02c03271;MF=hillf.zj@alibaba-inc.com;NM=1;PH=DS;RN=22;SR=0; Reply-To: "Hillf Danton" From: "Hillf Danton" To: "'Russell King - ARM Linux'" , "'Jungseung Lee'" Cc: "'Shailendra Verma'" , "'Greg Kroah-Hartman'" , "=?iso-8859-1?Q?'Arve_Hj=F8nnev=E5g'?=" , "'Riley Andrews'" , "'Laura Abbott'" , "'Shailendra Verma'" , "'Dan Carpenter'" , "'Mitchel Humpherys'" , "'Sumit Semwal'" , "'Kirill A. Shutemov'" , "'Gioh Kim'" , "'Rasmus Villemoes'" , "'Shawn Lin'" , "'Markus Elfring'" , , , "'Ravikant Bijendra Sharma'" , "'Shailendra Verma'" , , References: <1447055848-28180-1-git-send-email-shailendra.v@samung.com> <20151109160137.GA8644@n2100.arm.linux.org.uk> In-Reply-To: <20151109160137.GA8644@n2100.arm.linux.org.uk> Subject: Re: [PATCH] arch:arm:mm:Correction in the boundary check for module end address. Date: Tue, 10 Nov 2015 10:50:40 +0800 Message-ID: <049601d11b62$986780c0$c9368240$@alibaba-inc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQEzdE8YQ08Kj5xPjRRoSJYX0l96SwOEdww6AolXra2fn2wVEA== Content-Language: zh-cn Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2958 Lines: 81 > On Tue, Nov 10, 2015 at 12:35:50AM +0900, Jungseung Lee wrote: > > Hi, > > > > 2015-11-09 16:57 GMT+09:00 Shailendra Verma : > > > From: Shailendra Verma > > > > > > 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 > > > Reviewed-by: Ravikant Bijendra Sharma > > > --- > > > 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. > Would you please respin, Shailendra, with Russell's comments addressed, and with Reported-by: Hillf Danton ? thanks Hillf -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/