lkml.org 
[lkml]   [2022]   [Oct]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] vsprintf: protect kernel from panic due to non-canonical pointer dereference
Date
On 10/18/2022 12:28 PM, Randy Dunlap wrote:
> Hi--
>
[..]
>>>> That said, I realized that not all
>>>> architecture implement meaningful kern_addr_valid(), so this line
>>>> if ((unsigned long)ptr < PAGE_SIZE || IS_ERR_VALUE(ptr))
>>>> is still need. I'll send v2.
>>>
>>> Please, add linux-mm@kvack.org into CC.
>>
>> Will do.
>>
>>> I wonder if kern_addr_valid()
>>> is safe to use anywhere, especially during early boot. I wonder if
>>> it would make sense to implement it on all architectures.
>>
>> On x86 architecture, kern_addr_valid() looks safe to me though, on
>> several other architectures, it's defined (1).
>
> You might want to compare this patch, which seems to have some support:
>
> https://lore.kernel.org/lkml/20221018074014.185687-1-wangkefeng.wang@huawei.com/
>

Thank you for alerting me, appreciated!

The patch comment says "copy_from_kernel_nofault() which could check
whether the address is a valid kernel address, so no need
kern_addr_valid()", I'm afraid copy_from_kernel_nofault() is more of a
heavy hammer, and less appropriate for this patch. I'll take a closer
look before responding to the submitter.

thanks!
-jane
\
 
 \ /
  Last update: 2022-10-18 21:59    [W:0.122 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site