Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2328119imm; Thu, 7 Jun 2018 08:52:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKHDo4LfYfavJTrW7Pf2JnfYzhjtU0z2FLSvQabZ3D2hEQCJMYfhiwdLVRsULuHP9reaTiV X-Received: by 2002:a62:a50c:: with SMTP id v12-v6mr2263555pfm.237.1528386723767; Thu, 07 Jun 2018 08:52:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528386723; cv=none; d=google.com; s=arc-20160816; b=O3idRry1tdMaNZk7T1cnOQmctk1I8HJ+51eGOIUwEaD6sBSOGoYoysp+dKYMgls6bI LCef3/11iWyyXGYB5rh+lchP6u6Dhn9J76zpytEvBDKRZj5jMZJ6n0QuOETBWSOd8y8b hQmzzEwWLePFcwuXwDJO2CNSzxz8sSc0pMe2idKJIOmF/OCnStAXHd7B7rh1Veyrm8AQ 5P5O9Eei5lfl550A0o8VI80axUVhAqGIaoVgczmRIlsnOUfIxiuHMD4QpFxcTfBNSftm LCeWhNVGWvBk1giujf3cP3De+q62rpYMgqo00utUpfOvRxUyBw8tNmtIU1JUZ7nwyTkp WOGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=EvuN2yvM+63H9gpin/7TxS88xGskAp9CbhN+M7Jv1U0=; b=06pUeASV7VYxUliewDbveT7OTw8w3ptCD1a50ixDQeOxGV1emAxrKCWZIG2Ri2Xvx5 wWeoYbbn1M07nMSa6YuTte5ExoS9cJckrkIBNfGFyZ2+dPmfhcDdRTA9EsD4ClggfVLg HkggPOK91FMUUHo/oyU5VdpaFKBMdwmDDIlV6erb8pl4Ce0BtA1RQoN0JQO5gYELo3UP t0zAmNmpcAIqn6Zf2hVBuxUqx52RQG+8C1N95AHiyBf55nfXA8wxjBzO05hreCdvskk9 eK5fFcZMB+KGZn7P3tXlrw5MjFVPLsUcaBmsBYo5BZtTSMz2m39miPNt/gbni92MjWbs IAQw== 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 t127-v6si5111884pfc.174.2018.06.07.08.51.49; Thu, 07 Jun 2018 08:52:03 -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; 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 S934374AbeFGOj5 (ORCPT + 99 others); Thu, 7 Jun 2018 10:39:57 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:40523 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934351AbeFGOjz (ORCPT ); Thu, 7 Jun 2018 10:39:55 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbL-0005Zs-O3; Thu, 07 Jun 2018 15:09:19 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvbE-0003IN-TH; Thu, 07 Jun 2018 15:09:12 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Michal Hocko" , "Vlastimil Babka" , "Linus Torvalds" , "Yisheng Xie" , "Alexander Potapenko" , "Dmitriy Vyukov" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 391/410] mm/mempolicy.c: avoid use uninitialized preferred_node In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Yisheng Xie commit 8970a63e965b43288c4f5f40efbc2bbf80de7f16 upstream. 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: Ben Hutchings --- mm/mempolicy.c | 3 +++ 1 file changed, 3 insertions(+) --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2160,6 +2160,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();