From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752825AbcA0BUW (ORCPT ); Tue, 26 Jan 2016 20:20:22 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:3448 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751803AbcA0BUE (ORCPT ); Tue, 26 Jan 2016 20:20:04 -0500 Message-ID: <56A81B01.7010104@huawei.com> Date: Wed, 27 Jan 2016 09:18:57 +0800 From: Xishi Qiu User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Mark Rutland CC: zhong jiang , Laura Abbott , Hanjun Guo , "linux-arm-kernel@lists.infradead.org" , LKML Subject: Re: Have any influence on set_memory_** about below patch ?? References: <5693A740.7070408@huawei.com> <20160111133145.GM6499@leverpostej> <569454F6.1060207@huawei.com> <20160112111531.GA4858@leverpostej> <5695DA67.5080201@huawei.com> <20160113112813.GE23370@leverpostej> In-Reply-To: <20160113112813.GE23370@leverpostej> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.25.179] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.56A81B0C.0125,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 5b2e8da8845bf286e623ba3de4429c64 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/1/13 19:28, Mark Rutland wrote: > On Wed, Jan 13, 2016 at 01:02:31PM +0800, Xishi Qiu wrote: >> Hi Mark, >> >> If I do like this, does it have the problem too? >> >> kmalloc a size >> no access >> flush tlb >> call set_memory_ro to change the page table flag >> flush tlb >> start access > > This is broken. > > The kmalloc will give you memory form the linear mapping. Even if you > allocate a page, that page could have been mapped with a section at the > PMD/PUD/PGD level. > > Other data could fall within that section (e.g. a kernel stack, > perhaps). Hi Mark, If nobody use that whole section before(however it is almost impossible), flush tlb is safe, right? Thanks, Xishi Qiu > > Additional TLB flushees do not help. There's still a race against the > asynchronous TLB logic. The TLB can allocate or destroy entries at any > tim. If there were no page table changes prior to the invalidate, the > TLB could re-allocate all existing entries immediately after the TLB > invalidate, leaving you in the same state as before. > > Thanks, > Mark. > > . >