Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1624995

Re: [PATCH V2] mm/madvise: Move up the behavior parameter validation

From Anshuman Khandual <khandual@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject Re: [PATCH V2] mm/madvise: Move up the behavior parameter validation
Date 2017-04-18 04:50 +0200
Message-ID <txrnj-w5-3@gated-at.bofh.it> (permalink)
References <tvJeG-Wr-23@gated-at.bofh.it> <tw9Vw-1JY-7@gated-at.bofh.it> <tx7oC-5as-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 04/17/2017 10:57 AM, Naoya Horiguchi wrote:
> On Fri, Apr 14, 2017 at 07:21:41PM +0530, Anshuman Khandual wrote:
>> The madvise_behavior_valid() function should be called before
>> acting upon the behavior parameter. Hence move up the function.
>> This also includes MADV_SOFT_OFFLINE and MADV_HWPOISON options
>> as valid behavior parameter for the system call madvise().
>>
>> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
>> ---
>> Changes in V2:
>>
>> Added CONFIG_MEMORY_FAILURE check before using MADV_SOFT_OFFLINE
>> and MADV_HWPOISONE constants.
>>
>>  mm/madvise.c | 9 +++++++--
>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/mm/madvise.c b/mm/madvise.c
>> index efd4721..ccff186 100644
>> --- a/mm/madvise.c
>> +++ b/mm/madvise.c
>> @@ -694,6 +694,10 @@ static int madvise_inject_error(int behavior,
>>  #endif
>>  	case MADV_DONTDUMP:
>>  	case MADV_DODUMP:
>> +#ifdef CONFIG_MEMORY_FAILURE
>> +	case MADV_SOFT_OFFLINE:
>> +	case MADV_HWPOISON:
>> +#endif
>>  		return true;
>>  
>>  	default:
>> @@ -767,12 +771,13 @@ static int madvise_inject_error(int behavior,
>>  	size_t len;
>>  	struct blk_plug plug;
>>  
>> +	if (!madvise_behavior_valid(behavior))
>> +		return error;
>> +
>>  #ifdef CONFIG_MEMORY_FAILURE
>>  	if (behavior == MADV_HWPOISON || behavior == MADV_SOFT_OFFLINE)
>>  		return madvise_inject_error(behavior, start, start + len_in);
>>  #endif
>> -	if (!madvise_behavior_valid(behavior))
>> -		return error;
> 
> Hi Anshuman,
> 
> I'm wondering why current code calls madvise_inject_error() at the beginning
> of SYSCALL_DEFINE3(madvise), without any boundary checks of address or length.
> I agree to checking madvise_behavior_valid for MADV_{HWPOISON,SOFT_OFFLINE},
> but checking boundary of other arguments is also helpful, so how about moving
> down the existing #ifdef block like below?

Sure, will fold both the patches together and send it out.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] mm/madvise: Move up the behavior parameter validation Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2017-04-13 11:30 +0200
  Re: [PATCH] mm/madvise: Move up the behavior parameter validation kbuild test robot <lkp@intel.com> - 2017-04-13 16:00 +0200
  [PATCH V2] mm/madvise: Move up the behavior parameter validation Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2017-04-14 16:00 +0200
    Re: [PATCH V2] mm/madvise: Move up the behavior parameter validation Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> - 2017-04-17 07:30 +0200
      Re: [PATCH V2] mm/madvise: Move up the behavior parameter validation Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2017-04-18 04:50 +0200
  [PATCH V3] mm/madvise: Move up the behavior parameter validation Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2017-04-18 07:30 +0200
    Re: [PATCH V3] mm/madvise: Move up the behavior parameter  validation David Rientjes <rientjes@google.com> - 2017-04-18 23:10 +0200
    Re: [PATCH V3] mm/madvise: Move up the behavior parameter validation Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> - 2017-04-19 02:50 +0200

csiph-web