Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp836206imu; Thu, 3 Jan 2019 08:01:00 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wdi8BUEuG0sAeTB5ogHNdnQmWTNsteEv4CCaeZZedMUOnv2vfxQ+1uQOLEldsoTAAbRCJm X-Received: by 2002:a62:c28e:: with SMTP id w14mr48759848pfk.115.1546531260546; Thu, 03 Jan 2019 08:01:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546531260; cv=none; d=google.com; s=arc-20160816; b=WY1cH0q0QDr051TuXVFQBTIfOc63phEfOZEPaV/rfPPfSJ3T+KhU1pwFb3LazCNAwN wen4Mga4ujU6WDUdnJ36uIkH57pdF38fXT5/kweyThFhUnPYdOyZ251QUZ2EAM6PE8NO fvZPy6kWK38SMb1TpGmmStXRzj9Bvg4KPNHaqpBfNdFEf/wGshcs+v8T5YInSHiC6x1a jYxoMdbwRmbvCWcLdq+nLGICgKy+iA2ZPiJGIo2v2lhqy1Fx8MOzt/tFhXita+Ev7dIu jLDwvBVN5h2dip91FkJ6yPHTBC5dZ3MwGD/vfiZ5PkfpiDj5BsFRa+RO6h8dHcm7mjjs xkjQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:openpgp:from:references:cc:to:subject; bh=+bgyrDHlzRjrLwVmvzbzZcPCEa/As57BY+F9ohIjdp8=; b=i2n2gbTME2NIoCFlgfFfaNW8Ji0rIBzV19p3VAj2i2rNdyjaFH2UBV4MS2ouOggPpX /iWgQWXTyoIxTdFUrxlnBICVz90BYAQan1gI+DlFFpTEFJU9WYzKehlBcP5cw7h5Uv/F jTFthpErN3SbhqHjZFnUTlFYow22CKBterSFvA4EDmwHP+pYa4WEWhKUCezl61YUO+MX dtBccmZwSW3rQyCajEQKeuD+UFR2c8cU6S1itZi9zUjlZiMhSXXdymXODxksWjKzBgP+ 62wzxpFAeX0JfL5+ubkfPc3FgKP1bBHLd4jNIshos7OLQyy0uTwWvJZM/V5XPVJH49mf x0ng== 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 31si17516195plz.263.2019.01.03.08.00.45; Thu, 03 Jan 2019 08:01:00 -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 S1731311AbfACLlu (ORCPT + 99 others); Thu, 3 Jan 2019 06:41:50 -0500 Received: from mx2.suse.de ([195.135.220.15]:59240 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726170AbfACLlt (ORCPT ); Thu, 3 Jan 2019 06:41:49 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EE07AAF8D; Thu, 3 Jan 2019 11:41:46 +0000 (UTC) Subject: Re: KMSAN: uninit-value in mpol_rebind_mm To: Alexander Potapenko , Dmitry Vyukov Cc: syzbot , Andrea Arcangeli , Andrew Morton , "Kirill A. Shutemov" , LKML , Linux-MM , linux@dominikbrodowski.net, Michal Hocko , David Rientjes , syzkaller-bugs , Yisheng Xie , zhong jiang References: <000000000000c06550057e4cac7c@google.com> From: Vlastimil Babka Openpgp: preference=signencrypt Message-ID: Date: Thu, 3 Jan 2019 12:41:45 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.3 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/3/19 12:14 PM, Alexander Potapenko wrote: > On Thu, Jan 3, 2019 at 9:42 AM Dmitry Vyukov wrote: >> >> On Thu, Jan 3, 2019 at 9:36 AM Vlastimil Babka wrote: >>> >>> >>> On 12/31/18 8:51 AM, syzbot wrote: >>>> Hello, >>>> >>>> syzbot found the following crash on: >>>> >>>> HEAD commit: 79fc24ff6184 kmsan: highmem: use kmsan_clear_page() in cop.. >>>> git tree: kmsan >>>> console output: https://syzkaller.appspot.com/x/log.txt?x=13c48b67400000 >>>> kernel config: https://syzkaller.appspot.com/x/.config?x=901dd030b2cc57e7 >>>> dashboard link: https://syzkaller.appspot.com/bug?extid=b19c2dc2c990ea657a71 >>>> compiler: clang version 8.0.0 (trunk 349734) >>>> >>>> Unfortunately, I don't have any reproducer for this crash yet. >>>> >>>> IMPORTANT: if you fix the bug, please add the following tag to the commit: >>>> Reported-by: syzbot+b19c2dc2c990ea657a71@syzkaller.appspotmail.com >>>> >>>> ================================================================== >>>> BUG: KMSAN: uninit-value in mpol_rebind_policy mm/mempolicy.c:353 [inline] >>>> BUG: KMSAN: uninit-value in mpol_rebind_mm+0x249/0x370 mm/mempolicy.c:384 >>> >>> The report doesn't seem to indicate where the uninit value resides in >>> the mempolicy object. >> >> Yes, it doesn't and it's not trivial to do. The tool reports uses of >> unint _values_. Values don't necessary reside in memory. It can be a >> register, that come from another register that was calculated as a sum >> of two other values, which may come from a function argument, etc. >> >>> I'll have to guess. mm/mempolicy.c:353 contains: >>> >>> if (!mpol_store_user_nodemask(pol) && >>> nodes_equal(pol->w.cpuset_mems_allowed, *newmask)) >>> >>> "mpol_store_user_nodemask(pol)" is testing pol->flags, which I couldn't >>> see being uninitialized after leaving mpol_new(). So I'll guess it's >>> actually about accessing pol->w.cpuset_mems_allowed on line 354. >>> >>> For w.cpuset_mems_allowed to be not initialized and the nodes_equal() >>> reachable for a mempolicy where mpol_set_nodemask() is called in >>> do_mbind(), it seems the only possibility is a MPOL_PREFERRED policy >>> with empty set of nodes, i.e. MPOL_LOCAL equivalent. Let's see if the >>> patch below helps. This code is a maze to me. Note the uninit access >>> should be benign, rebinding this kind of policy is always a no-op. > If I'm reading mempolicy.c right, `pol->flags & MPOL_F_LOCAL` doesn't > imply `pol->mode == MPOL_PREFERRED`, shouldn't we check for both here? I think it does? Only preferred mempolicies set it, including default_policy, and MPOL_LOCAL is converted to MPOL_PREFERRED internally. Anyway we would need the opposite implication here to be safe, and that's also true. >>> ----8<---- >>> From ff0ca29da6bc2572d7b267daa77ced6083e3f02d Mon Sep 17 00:00:00 2001 >>> From: Vlastimil Babka >>> Date: Thu, 3 Jan 2019 09:31:59 +0100 >>> Subject: [PATCH] mm, mempolicy: fix uninit memory access >>> >>> --- >>> mm/mempolicy.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/mm/mempolicy.c b/mm/mempolicy.c >>> index d4496d9d34f5..a0b7487b9112 100644 >>> --- a/mm/mempolicy.c >>> +++ b/mm/mempolicy.c >>> @@ -350,7 +350,7 @@ static void mpol_rebind_policy(struct mempolicy *pol, const nodemask_t *newmask) >>> { >>> if (!pol) >>> return; >>> - if (!mpol_store_user_nodemask(pol) && >>> + if (!mpol_store_user_nodemask(pol) && !(pol->flags & MPOL_F_LOCAL) && >>> nodes_equal(pol->w.cpuset_mems_allowed, *newmask)) >>> return; >>> >>> -- >>> 2.19.2 >>> >>> -- >>> You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group. >>> To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@googlegroups.com. >>> To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/a71997c3-e8ae-a787-d5ce-3db05768b27c%40suse.cz. >>> For more options, visit https://groups.google.com/d/optout. > > >