Received: by 2002:a05:7412:b112:b0:f9:3106:f1c0 with SMTP id az18csp31738rdb; Sun, 17 Dec 2023 19:34:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IHnnR4dk7z0pyT9AzGJICpTvq0qf9Yhan0XInoHpXpT7sztMvFng7LQ6pSREkwkWjV6w05X X-Received: by 2002:a17:902:868f:b0:1d3:b308:adb8 with SMTP id g15-20020a170902868f00b001d3b308adb8mr1261819plo.17.1702870494832; Sun, 17 Dec 2023 19:34:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702870494; cv=none; d=google.com; s=arc-20160816; b=vbjnbV20QC6fAS4zRGm7YD40l7GdI2eImTe+ODvhnNJMaC1tvgocpNt5NMJJrbqgL1 ZGdjFwy3oAkcREBJv17oE5llm/Df+1lQ4pm3Os4OXqnfz9/29QQS//y1YKVI/prJlT6p o7QKHwJ01tATBWJ0C7ekDkKJxI3FylEDUtGJj8f3nfeggRkHVmF9WxuH9GdwKV3U6XNa VZnzxfGMI8rICuAPm812KtChzpZiEQKRx43hoM00DCaJE3woZ0s3kp38bV6cYr8d0h9M eo5CBkc4CZjbkE3RaOQgzitDr2lgRLYaI4jziyY9RdLeBGyMFi+3d/lH3lZ3IelzUE8W 8ODw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id; bh=UIC2fpUrsQ8OkjbYEyNr2G6+no4enW/TOckRha0+ZH4=; fh=3/dyopnhBOjuve8XzuNy+s+MiC+/Uz/Nz+rL2MwH9Rk=; b=arZ3jkH7Hp11HK2cYNPBxy2ZfL0pQbGwxmKRLfs7qki6ws9SAOoc13giqCgVHDec2D zmqTX1IbdzDEuuhCT4tYHhO9Jo0QvGpD4T1d+52ctxbAJhSjgI9ipL0lbDquE+4EUoge xUD2RS2LVni7ZWjcpT08CGPm4gVz2/PDqA4WXaEuM/ukKOKsDKK5+z0rkoV6huQVLaoe qdCD4pyeXgM21HVKKud/jxvogcjEDrXsv6Q7ljza71ig692KBrsyIQLuezI3JMfsaONO 2T45qmDoIOexu6J9MYpZnGgMPVpOpmQrQnR6UjwDIi0LUS5Qx14bV3hYZ5mEq5DmNJ/z cRyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-2974-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2974-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id s20-20020a170902a51400b001d3b33d9e0dsi1363354plq.99.2023.12.17.19.34.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 19:34:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2974-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-2974-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2974-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7F7DD2826A7 for ; Mon, 18 Dec 2023 03:34:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1E5C46FD1; Mon, 18 Dec 2023 03:34:48 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04CF96FBF for ; Mon, 18 Dec 2023 03:34:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0Vye9d5e_1702870475; Received: from 30.97.48.59(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0Vye9d5e_1702870475) by smtp.aliyun-inc.com; Mon, 18 Dec 2023 11:34:36 +0800 Message-ID: <874cce7f-4545-450f-9d6b-4f3e3357281b@linux.alibaba.com> Date: Mon, 18 Dec 2023 11:34:59 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm: migrate: fix getting incorrect page mapping during page migration To: Matthew Wilcox Cc: akpm@linux-foundation.org, david@redhat.com, ying.huang@intel.com, ziy@nvidia.com, xuyu@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/15/2023 11:01 PM, Matthew Wilcox wrote: > On Fri, Dec 15, 2023 at 02:51:43PM +0000, Matthew Wilcox wrote: >> I'm not saying no to this fix, but dump_mapping() is supposed to be >> resilient against this. Is the issue that 'dentry' is NULL, or is it >> some field within dentry that is NULL? eg, would this fix your >> case? > > Uh, dentry is an on-stack dentry. So obviously it's a pointer within it > that's NULL. Maybe this, having stared at the implementation of %pd? Yes, I think below check can avoid crash of dentry_name() used by '%pd'. Maybe we should also initialize on-stack dentry by struct dentry dentry = { }; I can send a patch with your suggestion. Thanks. > +++ b/fs/inode.c > @@ -588,7 +588,8 @@ void dump_mapping(const struct address_space *mapping) > } > > dentry_ptr = container_of(dentry_first, struct dentry, d_u.d_alias); > - if (get_kernel_nofault(dentry, dentry_ptr)) { > + if (get_kernel_nofault(dentry, dentry_ptr) || > + !dentry->d_parent || !dentry->d_name) { > pr_warn("aops:%ps ino:%lx invalid dentry:%px\n", > a_ops, ino, dentry_ptr); > return;