From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B88CAC3600C for ; Thu, 3 Apr 2025 15:14:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C586280005; Thu, 3 Apr 2025 11:14:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 27561280001; Thu, 3 Apr 2025 11:14:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13B9F280005; Thu, 3 Apr 2025 11:14:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E9CC4280001 for ; Thu, 3 Apr 2025 11:14:17 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 92E8A56ACD for ; Thu, 3 Apr 2025 15:14:19 +0000 (UTC) X-FDA: 83293078638.03.72C9663 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by imf06.hostedemail.com (Postfix) with ESMTP id B1A14180015 for ; Thu, 3 Apr 2025 15:14:17 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b="EK/ul85n"; spf=pass (imf06.hostedemail.com: domain of dan.carpenter@linaro.org designates 209.85.221.46 as permitted sender) smtp.mailfrom=dan.carpenter@linaro.org; dmarc=pass (policy=none) header.from=linaro.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743693257; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zesTfvhE2YJxqZrUkOmQImcB4JZs5LCDw+hQnMIH21A=; b=5fgJwpSKT1OLiIBC67qbA/Z65tSdqLSsqhgs9IWfGAg4RcXKpV+OKZpaZ2ZTDvTl/csr4Z V7YkmBKQ4v+u9lOBJHEm3k/Z33O/VYs+LxherTW6zjAAvR23so09WNE2meKIwWFJX3ZqUP WX41P2+WzgbE55mxALOek5s/9DBiq7o= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b="EK/ul85n"; spf=pass (imf06.hostedemail.com: domain of dan.carpenter@linaro.org designates 209.85.221.46 as permitted sender) smtp.mailfrom=dan.carpenter@linaro.org; dmarc=pass (policy=none) header.from=linaro.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743693257; a=rsa-sha256; cv=none; b=hOyMRsPs2CgEDEqT3mhxtw2Qz1x7lFcrPW70etObq9Rpg0ThUMt2LikIrxLKSF6xNnubzz v53qE6PEeDEdo2mWMaTN+Q5GMBOJjFgYG56NAC8688r5Zmcf9jRZCF5ZULtw7C0M+kPaOJ it3Vzv0pR1czJyIKRl3xIfADccBzRQ0= Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-3914aba1ce4so903655f8f.2 for ; Thu, 03 Apr 2025 08:14:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1743693256; x=1744298056; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=zesTfvhE2YJxqZrUkOmQImcB4JZs5LCDw+hQnMIH21A=; b=EK/ul85nQ/efKnP3xST2hCcRPt0JAd1qsK1FqHCMowEypwEbYVfAxT4/SEgzok5Sr2 Ez1C1urusiSotkk6XSvdzBBCVXauysTJDWzEK1/lausX2nuDnvcPlCIMDRMy7sQ2WggV dgVcHmA7vOa4mSgtB3b7S3Z7vaGS3tSMr2EUx2gukXY2tvGhJERi+Ay5jpdRz0IxNqsV M2/Ey2Ipovd+sokt985Pydw+iFl4WtomaN68A7TbHNP5E571VJwyNsn83k45s3e11YvV z8TGAuZQbB/sZecuvMSYrRhXE5vg4ZzDw1aLXUYmVja91TxjO6t4XnuewfY0ZPhvgM26 bupA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743693256; x=1744298056; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zesTfvhE2YJxqZrUkOmQImcB4JZs5LCDw+hQnMIH21A=; b=tghrJ42JTi9PBHXe7znKp4kcKSzOO4cpEM6omHtgpsT9RBdEZUmTVFHk/5U3Kc0fF2 Xm/ivsS8ZD0OTvrBkHy3u3L1iuh9I4RNnie4QgKETIOVCOxW0GROjbSza1z3f3Nexwbm xh8ofoG+ngT0bVSKutISZtMS2dMifU4tZa/yq82EZkdnxf8UmWXbjkSyjLUYHi0GBQrb UZC56v0Ntbf5+1fQeiuHnNZ1RV73U7XkqDhO9V1i2oBil3U85UNWOWuAFEyKdwHO2fKR i5eWt0i25C5YKvkckcunwV/Cveu+Y4qBORTAOsPHzWG9sJrGH/Y/cu0umuAQeLieS8wZ 6Gmg== X-Forwarded-Encrypted: i=1; AJvYcCVl6wVjWXrKLwnGQBwlG532Dkqe9zC9fb+A778/VrRE7KBZRaWiswy0jYWIwcUoAXOFNaOI+/N0zA==@kvack.org X-Gm-Message-State: AOJu0YxXCB1GQjnpyx/aakWKWkARPdKces8xa1Ian5IgHFaWnGuPsa/W qedT+f/Ue5fdz8iJchVGKXUUuslQYdRtVwbYT+7rwXS9N3/l3ussxc2e+azyczQ= X-Gm-Gg: ASbGncvf+iNc5OVNWjcwvW57mtIbAvk8xBuTSzZ3Ty+1gum6nh1CI3n7jxKBpCp5+uL BaAETWpuLldP6+5+Fn6H4jzJ/Njcc8xqXI9Z0T5nNKZvnC7uk49jI1kMCsRRe71WfSZedpoavRk Nz1yD64kpjGPBIE/bACIsC0NE2wyUFMqKrhW7qy+xWPiNcHnfGnvu2tZDtJktrY5EQZSao5r1y0 BRY941y2vsVwk9WSoWyT2Ag2kgCjSOGAPcBHHzV+8ddQLhLYbtXhTPMSkjsB7h647BqIFcyPEL4 e6/VjNRdiAGoeLM0AcB+2adWGD0nVDngibvEimavd1yn9/Ymwg== X-Google-Smtp-Source: AGHT+IFMCCjbDEb0ODe6Sl1fKegMQn7DnIEF6seKhoqCEcHbDlk903Mu/qkvcsEO6a7wEAqglg0Faw== X-Received: by 2002:a05:6000:290f:b0:390:f552:d291 with SMTP id ffacd0b85a97d-39c120dc53emr22332900f8f.22.1743693255931; Thu, 03 Apr 2025 08:14:15 -0700 (PDT) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-39c301a6796sm2085299f8f.31.2025.04.03.08.14.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Apr 2025 08:14:15 -0700 (PDT) Date: Thu, 3 Apr 2025 18:14:11 +0300 From: Dan Carpenter To: Lorenzo Stoakes Cc: David Hildenbrand , kernel test robot , oe-kbuild@lists.linux.dev, Dan Carpenter , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Liam R. Howlett" , x86@kernel.org Subject: Re: [PATCH v3] x86/mm/pat: Fix VM_PAT handling when fork() fails in copy_page_range() Message-ID: <94c35e89-f915-4122-b1a0-436893201373@stanley.mountain> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: B1A14180015 X-Stat-Signature: usgoxnshhsbbazp4dwkqw9nnir7ocopx X-HE-Tag: 1743693257-828972 X-HE-Meta: U2FsdGVkX1+0t/145TyVIWWD3Q1eAaZf+i4fYiyFVrkoYTTxOdE7pnbTfw5vU8JH3ATErRaYd2JVowd6TKQzD+Z5HY6hHGCxoW8mI2waE7onBXQFiBPBxDFFYdOT1D6YzQAhliRsTWjvgx65JpMLVuW1TnkToDorgi+C+oSudYwbW1GBfbFBqopIMAJEmZYwt9V8mZIvt6LGbRIPfinJlGkQVcv/WMYyVMouJJp/QMqj4r4neX1ht8m+lupxPabp9dsNtpzUwnLX9hUDQWK02uNR4TWNVUHj0ciHwdicTuFpSPV/yy0J5fTu7HstCknkIZrydM8Xr4fu3Uc4KzFjXtwXZElxP9tfAwYA8okHdDYV0wyBMRKOUsOBz8jrqSp5uQktQw+sAfVgcSSO8MhQN55WRtHCDcPs09yNrRJv+Ymh9zXuewFVR3yw8UZg5Kc8pVJtWtp/B14bCdVKJWGiZnR3MrlGzFhRV/kxY7v8yNo9cXBIgyAH6HRsZ50YOgLON2TjWQ4VuVX1sy/qwaIypjcHeONmshG7U6N48hd4Mu6BmtkLN2PEiZyKqvAfBecwJw0ByYliO09pIVr7CAR+OUofk6HPiP1XQ5GTOA7CUy+j+LI++Hx7dTI2OELTi2xZTNv4sVrR3hhjckLLy/cJs5rd3SvJ5Dvu8Lfli6OYvMDCZ7ICirR28teE2ljdJnRTjC1Q8B+NQpLVJs1hank3avsYZKmNaRf1Xhc9Z30AUOqHWXCpQKiuXlW1HIoGqLqFgR9l0YnqdYbgMMu76+K/DWcMhBE1if/P4FIl3CXrFPhaY3i0LLvuBgA/cOEJeandezrwEWzsb1nyBLsEDInySWmsh73IdhbjqbGzUEznGYFj5/NUMlBiVtE/KFXH5jfYGOdiRg0q3w4ygBpg1rMT1GqE8f6/wx54Pu7AwX53IXoWd/vaB8qKgm+Fh3Q8/mfAtIvx79pFTms+1zOIG5i FDfFeoyN XSmDap3+31PHL5U5wCioWnGz9OQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Sorry, I've been having trouble with my email recently... I replied earlier but my email got eaten on the way out. What happened here is that the zero day bot emails go to me first and then I review them or forward them depending on if they're a real issue or not. Here it's a false postive because it's set and used if the (src_vma->vm_flags & VM_PFNMAP) flag is set. Smatch doesn't parse this correctly. I've been meaning to fix this in Smatch for a while. But these days more and more people are using lei and b4 to get their email so they see the unreviewed Smatch warnings. regards, dan carpenter On Wed, Apr 02, 2025 at 12:37:24PM +0100, Lorenzo Stoakes wrote: > Bcc: > Subject: Re: [PATCH v3] x86/mm/pat: Fix VM_PAT handling when fork() fails in > copy_page_range() > Message-ID: <0f94adaf-37a4-4d38-b952-01c2dc474a2c@lucifer.local> > Reply-To: > In-Reply-To: > > Actually let me +cc a few more so this isn't lost further :P > > On Wed, Apr 02, 2025 at 01:32:52PM +0200, David Hildenbrand wrote: > > On 02.04.25 13:19, Lorenzo Stoakes wrote: > > > On Thu, Mar 27, 2025 at 09:59:02AM +0800, kernel test robot wrote: > > > > BCC: lkp@intel.com > > > > CC: oe-kbuild-all@lists.linux.dev > > > > In-Reply-To: <20250325191951.471185-1-david@redhat.com> > > > > References: <20250325191951.471185-1-david@redhat.com> > > > > TO: David Hildenbrand > > > > > > > > Hi David, > > > > > > > > kernel test robot noticed the following build warnings: > > > > > > > > [auto build test WARNING on 38fec10eb60d687e30c8c6b5420d86e8149f7557] > > > > > > > > url: https://github.com/intel-lab-lkp/linux/commits/David-Hildenbrand/x86-mm-pat-Fix-VM_PAT-handling-when-fork-fails-in-copy_page_range/20250326-032200 > > > > base: 38fec10eb60d687e30c8c6b5420d86e8149f7557 > > > > patch link: https://lore.kernel.org/r/20250325191951.471185-1-david%40redhat.com > > > > patch subject: [PATCH v3] x86/mm/pat: Fix VM_PAT handling when fork() fails in copy_page_range() > > > > :::::: branch date: 31 hours ago > > > > :::::: commit date: 31 hours ago > > > > config: hexagon-randconfig-r073-20250327 (https://download.01.org/0day-ci/archive/20250327/202503270941.IFILyNCX-lkp@intel.com/config) > > > > compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project c2692afc0a92cd5da140dfcdfff7818a5b8ce997) > > > > > > > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > > > > the same patch/commit), kindly add following tags > > > > | Reported-by: kernel test robot > > > > | Reported-by: Dan Carpenter > > > > | Closes: https://lore.kernel.org/r/202503270941.IFILyNCX-lkp@intel.com/ > > > > > > > > smatch warnings: > > > > mm/memory.c:1428 copy_page_range() error: uninitialized symbol 'pfn'. > > > > Huh, > > > > how did the original report not make it into my inbox ? :/ > > Yeah it's odd... maybe broken script? > > > > > Thanks for replying Lorenzo! > > NP! > > > > > > > > > I have a feeling this is because if ndef __HAVE_PFNMAP_TRACKING you just > > > don't touch pfn at all, but also I see in the new track_pfn_copy() there > > > are code paths where pfn doesn't get set, but you still pass the > > > uninitialised pfn to untrack_pfn_copy()... > > > > If track_pfn_copy() returns 0 and VM_PAT applies, the pfn is set. Otherwise > > (returns an error), we immediately return from copy_page_range(). > > > > So once we reach untrack_pfn_copy() ... the PFN was set. > > > > In case of !__HAVE_PFNMAP_TRACKING the pfn is not set and not used. > > > > > > > > I mean it could also be in the case of !(src_vma->vm_flags & VM_PAT) (but & > > > VM_PFNMAP), where we return 0 but still pass pfn to untrack_pfn_copy()... > > > > I assume that's what it is complaining about, and it doesn't figure out that > > the parameter is unused. > > > > So likely it's best to just initialize pfn to 0. > > > > > > > > This is all super icky, we probably want to actually have track_pfn_copy() > > > indicate whether we want to later untrack, not only if there's an error. > > > > Sounds overly-complicated. But having a pfn != 0 might work. > > > > > > Will comment accordingly on patch, but I mean I don't like the idea of > > us > > > just initialising the pfn here, because... what to?... :) > > > > Sure, I mean for all of above let's have the debate on the main patch I guess so > it's in one place... > > > Stared at that code for too long (and I reached a point where the PAT stuff > > absolutely annoys me). > > But, also lol. Can. Relate. > > > > > Thanks! > > > > -- > > Cheers, > > > > David / dhildenb > > > > Cheers, Lorenzo