Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2513226imm; Mon, 28 May 2018 09:30:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrwRmeSMnEjpsdzLcYGbthXs1fMr3z2bPGXMAGvvvRQukZJhTQIJX2W2Ou014aSEqD9/K0I X-Received: by 2002:a62:e408:: with SMTP id r8-v6mr14154360pfh.172.1527525008253; Mon, 28 May 2018 09:30:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527525008; cv=none; d=google.com; s=arc-20160816; b=a0jWIRVHV04+QkN7pRkRcoLL4UG+FUwS2DuPijGAJSchsevD89BcUkmFeFdy5heqx7 lTCfsaXVWhuaYZKBOx0ph51wb/F/CSC7/xN4joUJfIO/gjGEfoYdV8wLRLsrzNjAcEV0 RyXdpiTuc+UTBCnHgKXrunUzBwlpXgBU+36O9OicpjTK+adT0mQtn3fciS66L2y9qMB7 CKb2KfXaKT/3VD2B8NWlQhPCk/7HLsn0caPwE33Lvl8sxRi48OntVkBmyS0dM7UI0bd8 RiDCDs9ft9W6hiR9YEC2xV6oWvyuMdcX/bNOv75mZ6r+zVK/Ry3v48kFC71MFS9YoWRd hWwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=wyFj1PcYAwjdm3RecpkEajRFnW/VWrMjpYHHnJARZ7s=; b=tVQxZNGR59cRc3NaT96FuMZ1c4KuAhlyrJ0BhRSjcPZfQPphiAyX9ELkRDHEWD4tfH x/caQ06GtTcrPAizmLUgX9ADANZ5V2vM14A0Yt11T0h4pveZziOApUm+47SKL66B2m9N EHfwnWxeIiCvHvsBQHRBZShEzt7SjcAA8ZbNoCkHlU6O1AtqrowwFM5XWd/jVq8Ev0l4 ZddVDnc3/CZ+PVF76Npucxc3L+EdDUtvn+oQkVdzQmEywBJULaLbOPwJeX1Tj2pJDI+8 LCFkGqg6jGpMiVGpBeSKwjt+WJVvMTcYc7eHoeKEmp5L/EiC7KC3n5rt4T0xdLCBuw8Z baEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2Q1DeFeg; 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 k186-v6si8185903pge.375.2018.05.28.09.29.52; Mon, 28 May 2018 09:30:08 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=2Q1DeFeg; 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 S1425392AbeE1Q3O (ORCPT + 99 others); Mon, 28 May 2018 12:29:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:58206 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932226AbeE1KKC (ORCPT ); Mon, 28 May 2018 06:10:02 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2476F208C4; Mon, 28 May 2018 10:10:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502201; bh=nBlGYq8GL+6A93OxqP5bJwB+cAFIkIdt5eI/7TQt+Aw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2Q1DeFegRCWZkXXYdZtAkSP24gyPrvX0tdQnQ1HDNVNlMDJIfHH+ehYkgtFGBJafN 9ZW9pv59G+afKQpDi/NHo+vBzPTsBXCYSKZh92jGSPCs93yyv6umAGUso0hHZNN4OO Wnfzqce4k4TlW3C91ULAlVBAtvxCvsn7ngMiUWZc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yisheng Xie , Alexander Potapenko , Andrew Morton , Dmitriy Vyukov , Vlastimil Babka , Michal Hocko , Linus Torvalds , Sasha Levin Subject: [PATCH 3.18 098/185] mm/mempolicy.c: avoid use uninitialized preferred_node Date: Mon, 28 May 2018 12:02:19 +0200 Message-Id: <20180528100059.357697262@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100050.700971285@linuxfoundation.org> References: <20180528100050.700971285@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yisheng Xie [ Upstream commit 8970a63e965b43288c4f5f40efbc2bbf80de7f16 ] Alexander reported a 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 uses numa_node_id() instead of preferred_node, however, __mpol_equal() uses preferred_node without checking whether it is MPOL_F_LOCAL or not. [akpm@linux-foundation.org: slight comment tweak] Link: http://lkml.kernel.org/r/4ebee1c2-57f6-bcb8-0e2d-1833d1ee0bb7@huawei.com Fixes: fc36b8d3d819 ("mempolicy: use MPOL_F_LOCAL to Indicate Preferred Local Policy") Signed-off-by: Yisheng Xie Reported-by: Alexander Potapenko Tested-by: Alexander Potapenko Reviewed-by: Andrew Morton Cc: Dmitriy Vyukov Cc: Vlastimil Babka Cc: Michal Hocko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- mm/mempolicy.c | 3 +++ 1 file changed, 3 insertions(+) --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2169,6 +2169,9 @@ bool __mpol_equal(struct mempolicy *a, s 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();