Received: by 10.223.185.111 with SMTP id b44csp175847wrg; Fri, 9 Mar 2018 03:12:06 -0800 (PST) X-Google-Smtp-Source: AG47ELuHnD2OST0ujL4AKx9f4jNzEJHEAc7N8CMywIT7ZnqRuSDzuwYIniCs3ozVpdoINYoDk7of X-Received: by 10.99.111.196 with SMTP id k187mr23511188pgc.360.1520593926632; Fri, 09 Mar 2018 03:12:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520593926; cv=none; d=google.com; s=arc-20160816; b=mLPaXWPtzP5Pat7ucdzuW3VTOkwQiXTZR1qjCf4gCUO8V1ymT8QGf9sZQzN7009N4M x/jqleie6oD03xnC6OHgy7ySB7valHEousIijIksWpBV1ZjtCiPvu9LVgUf73966wBZH btwQSRR3YaF+FqlVkOEj3sw2fjxs2lmSKIdEN+2iOoUaRTBtIt8ocHNLpd62qTO3Qfoq U0CU8OSiialDZRLaboWE3Z33l6jOPE6yx4t9cB7n4Rpj2UJGgj4TzZ3f2hQ4XA6aiNHo hBgWxwGO32wfKEEM59OnpbI0+/DCu1Djsadmn5ycX98Dvk1zEdcOmRnQ53QQSSb3aYpI djyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=PJdyihKRfWMsUROsey4Lf+UWxCavI3cc16n85zyzr50=; b=fKNTtKZjzkPZ9OWUvc/rJJG9TOFL+JETOX8iHc8JrJwyBNg4bbb7p1lWZDd2zzjLE0 VR+1r7L8dqsdGyu8OH+A1qPV0weXmq2jDTdayazqybJhPh8IVdY73nmKkVZ1aZ4zfkru nxGzQunIR+h8lxKVrJXGLkAPgtlQE9Cg55BJlEkGoDIxZ1P3QEfhTSYztrxW5bc+Esja +/y301tWXLnrqFzpp0wBAp98E57BNiMjMv5CV7jwU2hkxwSxSSH4l/afl3zJ7ikp6COr 9CiGvQR3dMDt6+GplQNadTgpwN/oafv5ABoI2nu1qV+gUfXyQ6vDr+7xPv9P+L50qfZB 3nTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m5-v6si712568plt.235.2018.03.09.03.11.51; Fri, 09 Mar 2018 03:12:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751070AbeCILK6 (ORCPT + 99 others); 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 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 417D7FD9A312C; Fri, 9 Mar 2018 19:10:44 +0800 (CST) Received: from [127.0.0.1] (10.177.29.40) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.361.1; Fri, 9 Mar 2018 19:10:43 +0800 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 Precedence: bulk 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 >> > > >