Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796062450; b=fGTd15gYyDe4nv/RYpctEwhHvCnicAjCHDGKHuSfUjHV2+uvepmj92bJ+hIZs49QnbtQ e1l4QWFd/Uoe26NtLBAWaOo/90+1oP+m4Wf9UyW9ujbZM0tFWigRcIATX6/3PBTf15vDR ikpmAXqPPyUbbuvb7EfKva07G02x5MjMmZKBtYL8vsZbAaPOcDFJ38gm9byfbtp3677Y9 yvOrq5NPBaAm9tlfr7xoCNviJZ85NMZGChJwR7iKWRGuGZF6Ad+QrjSI1fJg7sRo/pPHM h2D+ZcFfR+MabfIVPf/+hNhS2CE8tBf14hgv1YeHUq9hBfz6eB2YtVrA6/4sINJiCIA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796062450; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: MIME-Version:Content-Type:Content-Transfer-Encoding:Subject:From:To: Cc:In-Reply-To:References:Date:Message-Id:X-Mailer; bh=vJIYckdDX3+h/32Lg6ZgofafJlFz0D8myHQvf+tGp8I=; b=R0yHsfmFt1V8EKnh0DMyjgs6mqLqPQEemnbNLpzJ7K5X1v8dzcNdN8dz0mAA4X71upVB C66viJwBTk6ryNk9l3N5wOiZeEX8l8cdCMOVZAqTNkVY2EZNkKIIWOJ4IMMuIl/9H3/+w madTb5rK+p0p7mbPGze4vVDgrdlzX/NqfBzH6LV7aq+qYUXHcrD2f2XLTNRJV2l3mJnpw 3hsadTvipocTqC3Sfo0DZrc9pu9QIhmYufPabZmEDvziMXakIKrOkOqtsqutzDbZ6Nc05 TWYw76wlO2x17OrEoeC9p6ByfSnfm4fMAX/2vU04U3iN12lHuXeg67v9Ua9DQ4rXBRQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass header.d=gourry.net header.i=@gourry.net header.a=rsa-sha256 header.s=google header.b=ZnepTiZn; arc=none smtp.remote-ip=209.85.219.46 Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56678606A33C for ; Mon, 30 Nov 2026 18:14:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 56678606A33C Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.a=rsa-sha256 header.s=google header.b=ZnepTiZn Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-92123f02faeso115141676d6.1 for ; Mon, 30 Nov 2026 10:14:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1796062447; x=1796667247; darn=vger.kernel.org; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:content-type:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=vJIYckdDX3+h/32Lg6ZgofafJlFz0D8myHQvf+tGp8I=; b=ZnepTiZnZ1XTJfHfmMfonDmnK8HSdprGzm+sY+dn0BMotiBDqpuWo91yI6j7ztOxGN cB/z1ZFlYnUvLaQOYhxcqV0F/0vpeVTEfc/2nZZcRdSplqIQ7XhL0KywNntPCo4za58A vV+YOvtFluIvZfejp+dqItLm8qAEiQ619Ga9ElGccrAKYerD1LTOiiESuYGxvjSvgyft NF8DLx/5vXLmnebaPwBvgVYKYFPeLgqP6v42QX3WAkfc1FpIG9ddGNYUr18/Prul0gBn YColCb4L6GqqnAOyhi+ZU3lniVeGPzqN0dSDb9APl+Fy0+L2Ak66a8aVe66PDtdMGCfm Fcsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796062447; x=1796667247; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:content-type:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=vJIYckdDX3+h/32Lg6ZgofafJlFz0D8myHQvf+tGp8I=; b=bnK9Ebl++0fAjOjF0FKBE/V4IW6cE70hPTM/5XkB8BOLXplVZdhWj9IvaPcuiLKsQf Bd6jyv9CZHmERBPasoBtej705Fbt01ofXs9smnddEt47JgPEOWZMpv1h2H7RHRuVcIIq XeTydZQb18Uo1TOBHj0JNU8OIEAdGQigG/vd/EyMod9xaLqKQIn4sgUewRn4F9QWZmjZ bD9k7p63kdGqos1OsvJigLHUbfC38df+5axj1t7TT6nZxve4STMmOla8t2GKnF5q2z9l Ze+FH2Ej3nzINaRg2bsb6Mmz7FhlWgufFIK6FjUieOXZivbFDQ6k7umBk9QwWT/bjZ4R 2QKg== X-Forwarded-Encrypted: i=1; AL+hErGkvUeBLWY8uaA4FKdXDMw3Sz8EywdDmaNNBG0WJC7KuVX9yTt3WszofDLev1+GweAZCJ4IW/FRICU=@vger.kernel.org X-Gm-Message-State: APuU4Z/s4BA2twjNH3S5VkiMJCCoelJtAN9jj9zzG60QrvgEv5r+UpTL p4B7VUI64w2ArzJfDSr5dDFeBEwHJH7+ND9Oyigd2y9RJmTh7JCZd9PzBwNAjHcsqGQ= X-Gm-Gg: AZFdTZe2xHhJZv0hH4RuFArAxNYQ0u2N1DvWDQ5G8xadiKUH65/pH47RmzJB9/+YGi9 xr4aeDP5I+2N2/TJMNK9A0wjHAgOQAWRe9jdvQ6IHYIS68pVeqJV7/64J+jBBtvorZe5PtTBeXe gU57tWAY/rivrRMXttmZOM+Fj0QhRQkX1hSoISP6DyNS3Ygrc23YdnNpDmHPhpJqwbBFGZE5VG2 xMZnc0FUuPBuDgGExaoWR1xHT3F+DXJpDZoP4dw7ck9RA6yEaQc8cDnJAGH3Udo+8EARPUtY9nX /3z7MXrCodxvqi1CBlxA1ChahnRwHoh4+21OR7OTdGZC7CmClwNttQFpCaI2wL7dApL8ALsGgsz ymheM5HQvyPo8ea542Iz7sF/GqKCvOOaFsqxjLQAzFQhLJUVJyBiD1JhqMwM98KpT2Xdg0GjUUh eS8Ov+6tlR5s4GIhs3nXszNvtIVEeClv/x+NnoNAmabTpeH4Unx8WQWzwo9UbPRI5TxCTYosX46 F3ju8KFSarnNvPLOmHyNcZOAAcT+PkoC+JNC5cULkXDgM5Xf7zNanoHHf5gQWrKjLYkbYlEpfvI b/jVBYf/H1yjXJLUamCMTmBHNpu1BcPMXuHP6uApzGagsK1/slEuxKS004CWyEzpRuTjM6DvHc6 iFubboz7ro1zdU0uf9WR5ZrXWDZ81Pw== X-Received: by 2002:a05:6214:8622:b0:921:7b03:3fa2 with SMTP id 6a1803df08f44-9217b0344e2mr331996596d6.55.1796062446965; Mon, 30 Nov 2026 10:14:06 -0800 (PST) Received: from [192.168.50.231] (pool-71-191-145-202.washdc.fios.verizon.net. [71.191.145.202]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-92134bfe82dsm298696636d6.0.2026.11.30.10.14.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 10:14:06 -0800 (PST) X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: Re: [PATCH 23/32] mm/mempolicy: check access under exec_update_lock From: "Gregory Price (Meta)" To: "David Hildenbrand (Arm)" Cc: Hugh Dickins , Baolin Wang , Andrew Morton , Mike Rapoport , Peter Xu , Michal Hocko , Kiryl Shutsemau , Manfred Spraul , Davidlohr Bueso , Cyrill Gorcunov , Zi Yan , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Lorenzo Stoakes , Rik van Riel , Vlastimil Babka , Harry Yoo , Jann Horn , Yang Shi , Zach O'Keefe , Song Liu , David Stevens , Kefeng Wang , Alex Williamson , Suren Baghdasaryan , Dave Jiang , Matthew Wilcox , Miaohe Lin , David Rientjes , Shakeel Butt , Jan Kara , Mel Gorman , Jason Gunthorpe , John Hubbard , Gerd Hoffmann , Vivek Kasireddy , Dave Airlie , Matthew Brost , Joshua Hahn , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Hagen Paul Pfeifer , James Bottomley , Felix Kuehling , Alex Sierra , Balbir Singh , Kairui Song , Qi Zheng , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Oscar Salvador , Muchun Song , Dan Williams , Rakie Kim , Hao Li , Christoph Lameter , Roman Gushchin , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt , Alexei Starovoitov , Xu Xin , Chengming Zhou , Shivank Garg , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cxl@vger.kernel.org, linux-rt-devel@lists.linux.dev, SJ Park , Chris Mason , Oleg Nesterov In-Reply-To: <20261129-fixes_core_3-v1-23-f66094116801@kernel.org> References: <20261129-fixes_core_3-v1-0-f66094116801@kernel.org> <20261129-fixes_core_3-v1-23-f66094116801@kernel.org> Date: Mon, 30 Nov 2026 13:14:04 -0500 Message-Id: <179606244459.412063.15223256711330589043.b4-reply@b4> X-Mailer: b4 0.17-dev On 2026-11-29 11:06 +0100, David Hildenbrand (Arm) wrote: > From: Chris Mason > > The access check in migrate_pages() can race with concurrent execve(): if > the target task execs a setuid binary, migrate_pages() can migrate the > pages of the new mm, which the checks would otherwise deny. The impact > is limited, but we should just handle it consistently. > > kernel_migrate_pages() calls ptrace_may_access() on the target and takes > its mm with get_task_mm() later, so the credentials that the check sees > have to belong to that mm. execve() replaces the mm in exec_mmap() and > the credentials in commit_creds(), and holds signal->exec_update_lock > for writing across both. > > Let's fix it by holding the target's exec_update_lock for reading until > we have grabbed the mm, as move_pages() does ever since > commit 13f77972b94c ("mm/migrate: find_mm_struct: fix race between > security checks and suid exec"). > > Regarding dropping the RCU read lock earlier, as explained by Oleg: > > "kernel_migrate_pages() calls ptrace_may_access() under rcu_read_lock() > for no reason. This is a leftover from before the commit 313674661925 > ("Unify migrate_pages and move_pages access checks"), where > rcu_read_lock() was needed to protect __task_cred(task). > > So we can drop the RCU lock right after get_task_struct()." > > Waiting for concurrent execve() is not really relevant, and move_pages() > already does the same. > > This has low urgency, as the impact is limited. No need to CC stable. > > Fixes: 313674661925 ("Unify migrate_pages and move_pages access checks") > Reported-by: Oleg Nesterov > Closes: https://lore.kernel.org/r/ahMt6xyUNnacZU8-@redhat.com > Suggested-by: Oleg Nesterov > Signed-off-by: Chris Mason > [ david: simplify description and comment ] > Signed-off-by: David Hildenbrand (Arm) Acked-by: Gregory Price (Meta) -- ~Gregory