From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751075AbeCILK6 (ORCPT ); Fri, 9 Mar 2018 06:10:58 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:49854 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751001AbeCILK5 (ORCPT ); Fri, 9 Mar 2018 06:10:57 -0500 Subject: Re: [PATCH] mm/mempolicy: Avoid use uninitialized preferred_node To: Alexander Potapenko References: <4ebee1c2-57f6-bcb8-0e2d-1833d1ee0bb7@huawei.com> CC: Andrew Morton , Linux Memory Management List , Dmitriy Vyukov , Vlastimil Babka , "mhocko@suse.com" , "Linux Kernel Mailing List" From: Yisheng Xie Message-ID: Date: Fri, 9 Mar 2018 19:10:43 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.29.40] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alexander , On 2018/3/9 18:49, Alexander Potapenko wrote: > On Fri, Mar 9, 2018 at 6:21 AM, Yisheng Xie wrote: >> Alexander reported an use of uninitialized memory in __mpol_equal(), >> which is caused by incorrect use of preferred_node. >> >> When mempolicy in mode MPOL_PREFERRED with flags MPOL_F_LOCAL, it use >> numa_node_id() instead of preferred_node, however, __mpol_equeue() use >> preferred_node without check whether it is MPOL_F_LOCAL or not. >> >> Reported-by: Alexander Potapenko >> Signed-off-by: Yisheng Xie > Tested-by: Alexander Potapenko Thanks, > > I confirm that the patch fixes the problem. Thanks for the quick turnaround! > Any idea which commit had introduced the bug in the first place? IIUC, It is introduce by: Fixes: fc36b8d3d819 (mempolicy: use MPOL_F_LOCAL to Indicate Preferred Local Policy) Thanks Yisheng >> --- >> mm/mempolicy.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/mm/mempolicy.c b/mm/mempolicy.c >> index d879f1d..641545e 100644 >> --- a/mm/mempolicy.c >> +++ b/mm/mempolicy.c >> @@ -2124,6 +2124,9 @@ bool __mpol_equal(struct mempolicy *a, struct mempolicy *b) >> case MPOL_INTERLEAVE: >> return !!nodes_equal(a->v.nodes, b->v.nodes); >> case MPOL_PREFERRED: >> + /* a's flags is the same as b's */ >> + if (a->flags & MPOL_F_LOCAL) >> + return true; >> return a->v.preferred_node == b->v.preferred_node; >> default: >> BUG(); >> -- >> 1.8.3.1 >> > > >