From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EEA44372AA0 for ; Thu, 20 Nov 2025 04:10:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763611846; cv=none; b=dt60fbi/SHqlq3Auplvkz8IcvzhIQREFR+UjhinhjFf+qNNWtBfi0l3428NbF/wjBOeHfMYiW+hy5W24qvDaSAvrJPRPgul+YOYHoDy2gsC8Ec3pCBQfiit3pY3kZBqBeOb9K1uBgm4Ogyx4Q300WLpoi96ClHwPqZa6C/phtYA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763611846; c=relaxed/simple; bh=2t7hmruR6MWJpSfcv7dicfOBqMxal2u0/ahXPnRgxiY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=owNiXt56I0KRaIzD6wqNa/OoTypf3NP8h6gmCo2CjT3Uqfgp469xM2YKzc1EdOMs7ED0pJwd4CvPRaqg/p7Nqo69xsEh54ReDP/3b2h9iPuqcomoTy0ossQZ0w2ErTSuRrp0ZbA7gHf+bxjF5EtKVFj/PvNRqwQ3Hkrl+/b4cNg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 66122FEC; Wed, 19 Nov 2025 20:10:36 -0800 (PST) Received: from [10.164.18.59] (MacBook-Pro.blr.arm.com [10.164.18.59]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6ED693F740; Wed, 19 Nov 2025 20:10:41 -0800 (PST) Message-ID: <01c00163-ec81-41ba-ba4d-c3425e2109f7@arm.com> Date: Thu, 20 Nov 2025 09:40:38 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] arm64/pageattr: Propagate return value from __change_memory_common To: Catalin Marinas Cc: will@kernel.org, ryan.roberts@arm.com, rppt@kernel.org, shijie@os.amperecomputing.com, yang@os.amperecomputing.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20251112062716.64801-1-dev.jain@arm.com> <20251112062716.64801-2-dev.jain@arm.com> Content-Language: en-US From: Dev Jain In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 19/11/25 11:33 pm, Catalin Marinas wrote: > On Wed, Nov 12, 2025 at 11:57:15AM +0530, Dev Jain wrote: >> The rodata=on security measure requires that any code path which does >> vmalloc -> set_memory_ro/set_memory_rox must protect the linear map alias >> too. Therefore, if such a call fails, we must abort set_memory_* and caller >> must take appropriate action; currently we are suppressing the error, and >> there is a real chance of such an error arising post commit a166563e7ec3 >> ("arm64: mm: support large block mapping when rodata=full"). Therefore, >> propagate any error to the caller. >> >> Fixes: a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full") >> Signed-off-by: Dev Jain >> --- >> v1 of this patch: https://lore.kernel.org/all/20251103061306.82034-1-dev.jain@arm.com/ >> I have dropped stable since no real chance of failure was there. > I couldn't figure out from the comments on v1 whether Will's concern was > addressed: > > https://lore.kernel.org/all/aQn4EwKar66UZ7rz@willie-the-truck/ > > IOW, is the patch necessary? What are the failure scenarios and what The patch is necessary because rodata=on requires us to proceed with set_memory_* *only* if the linear map alias permission change was successful. If we still go ahead with the set_memory_*, you now have memory in RO state, whereas the linear map alias is in RW state, defeating the purpose of rodata = on. > does the caller do? It's good to propagate an error to the caller but > patch also changes the current behaviour by bailing out earlier. The caller will get to know that set_memory_* failed. Since we may have bailed out partially in between the linear map alias permission change, we must also ensure that we change that memory back to RW - vm_reset_perms() will ensure that, and that change back to RW is *guaranteed* to succeed in the calls to set_area_direct_map() in vm_reset_perms(): as explained in the next patch, since that memory is non-RW, it is guaranteed to be pte-mapped. Now, it is the responsibility of the caller to pass VM_FLUSH_RESET_PERMS *before* it does set_memory_ro/set_memory_rox. If it doesn't, then the code is broken as is (Ryan noted earlier how this is a fragility in the vmalloc API and we should do something about it). >