Re: [PATCH v2] riscv: Fix permissions for all mm's during mm init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andrew,

01.09.2022 11:47, Andrew Jones wrote:
> On Tue, Aug 30, 2022 at 12:16:12PM +0300, Vladimir Isaev wrote:
>> It is possible to have more than one mm (init_mm) during memory
>> permission fixes. In my case it was caused by request_module
>> from drivers/net/phy/phy_device.c and leads to following Oops
>> during free_initmem() on RV32 platform:

>> +void fix_kernel_mem_early(char *startp, char *endp, pgprot_t set_mask,
>> +			  pgprot_t clear_mask)
>> +{
>> +	struct task_struct *t, *s;
>> +
>> +	unsigned long start = (unsigned long)startp;
>> +	unsigned long end = PAGE_ALIGN((unsigned long)endp);
>> +
>> +	__set_memory_mm(current->active_mm, start, end, set_mask, clear_mask);
>> +	__set_memory_mm(&init_mm, start, end, set_mask, clear_mask);
>> +
> 
> Presumably this is only run at a point where it's safe not to take
> tasklist_lock. A comment explaining that would be helpful to readers
> and help avoid this code getting copy+pasted into points it's not
> safe.
> 

Thanks for your review. I sent v3 with added comment and
WARN_ON(system_state != SYSTEM_FREEING_INITMEM), because looks like we can do
such mm-s change in this state only (both free_initmem() and mark_rodata_ro()
are called in this state).

Thank you,
Vladimir Isaev



[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux