From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CC6630FC0F for ; Thu, 23 Apr 2026 14:04:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776953069; cv=none; b=i3IEWV5urxy+ZO+UKqXn1ABjsVi+6J6WJkgDyOOmipSD38UC3dBvm1DUY/wl8RSk0WfGFBerBlcxiBcpV/KEhnoXjzUS6okH5JKDBR6bzHhJ42fk+IdYFzgExHHwQyfUUzw5hyuI9XbjiN2Mg+qKKJOS3u4bej9Jm5rmCY28tuo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776953069; c=relaxed/simple; bh=93DgQkvyCBKcB5iVjkvu47HUGp7BR5xEpAEy3kzg4Gk=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=r1w646p/cns/7f9NU6XO7JJQKyfyzyqNC5j9Bc1HU83aFCKED06qmXtgzbxrzipgzKC2Vw2j1yw/ltdOrAoFzQYeCmXtgQDEvQuUxIGZw1j3R1yug7fC2tVxYnyTyE+hashRAjbh8Mu+8mhWoLJXBBIHPPjI7TslZY9CujFvc4Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PlPAneEp; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PlPAneEp" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-43d73422431so5694435f8f.2 for ; Thu, 23 Apr 2026 07:04:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776953067; x=1777557867; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=3KWq8azbCSD7brpyXZ6QpBU16YtUoefjhmh1Zjdknw8=; b=PlPAneEptNA1rVpN8Yvj8bpDR7v6+MuTpAfa/OT0mOajhvvKu5lDO+DQqffF0qqOl8 65g55upfK54hjoS3NTPo8GEDHpdUU1CbOmg6cnxBHDelLJe/TftwO61k+qIfOaHYXwlC QqHV/Yumrp+t8QAGS3hrH/3TUFAiuE3j3xtrVx0JnVYzyfkJWxdFFmpH9ddhFb65CLVc GqiLSzr7taNsZ0i1IBW30JvmXvv4OttEzFqNavQG4i9KcEjgcFY5wJhF/AZhLNzp1KIL /2lPJfPMYjQJn85zvIcCq8lfe9TCYP5PriRZjWZ57vJU8aUntjNc8BVhSPUh2rgIKxN6 DyfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776953067; x=1777557867; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=3KWq8azbCSD7brpyXZ6QpBU16YtUoefjhmh1Zjdknw8=; b=bVQJ4lt2eN8zehQ8VPdICP47DBqTXHdGaZVTHb0wt+8F/TyIs9NwUfF1pDzlvGESje +XEV4A81GDIaxLD6zpoLbiQ2dM/Iw9v/y2vZNATs5N/LYEow5rG7QAia4DsrwF9sMxuo 6EV0axWhYqzcQT9QcNIOlsolX4pG1gUQW7IqAmswBEYcDRzGOqSirAy8zynuSjxwrl/o 5nr0AQg18oB4XQYjnv07szx8WmYWlRLSCqNOuSJZV4uGiTua+Acgj9FqvHWMneBjDlLr z8X35TJIQLggkV0pl6QzRhrodA8RnSYfcxDi1T+AlB00254K2SqctvnHPQhi8OJmgnkw 9elw== X-Forwarded-Encrypted: i=1; AFNElJ+bvKl/gZplZ0LjxCbTl2uRk1or9Qrf1+rB1d9R2eOdpftXy99NILY3hGXD4sLop1EqnEqvweHaHfQA624=@vger.kernel.org X-Gm-Message-State: AOJu0YxH6VIBTj+4lh1yvMKuMe45VD2nVAo6Jlgg40V1yNlduzCldXnb ox+RVVVTMR8CximroxcVb2S+hBvqxg802zEt01LePpZ69Le3gjNvG0jm X-Gm-Gg: AeBDietfUR5JVnEfhet/EM7koGliV3230hiuwqg0LHB5rBGrYGXwRayCBi7IKz2fjiM RhafOR0jIzjfyVysCtWYETVXC6s7qo9Op0SksZEfxAePgR5BwUqI0IhqpHCkBMPmQPzakZea5u5 v0T1n/r2itKJgigHIt4zlgSrWN7jA6592N1SDh/AW7KZfK0fHxTEMWnt+u/GU7eOcDG30osHU1g Q+WBrY5/5LV1STSArvHNvm+0al1UYOW5yivv7TEkwQlDnl3rsSWSXcYqKz2kiDZQ68wrISbTjfv J8PBItHNqgpf6hGxAz0anfFWFVJ6FRrgEFBwMo8AzzZTdNDRfcoHrjphWh9UIa2oywGmgGLOi4c DP/D3KRmOWcw7JqFfKUsINuwnmFONi4AVbeg6lqkX9u4Dmd8rBT6mgrcNI02SIBfypQNNOu7POy RF+MuNd/JIFt513Hlhdwa/+9wqpM9skbr05gU+C69RCXAafrjwTCOdQn5dDeo5WnINYxPhTq/4w 74= X-Received: by 2002:a05:6000:4283:b0:43d:7ea1:fb53 with SMTP id ffacd0b85a97d-43fe3e15f7emr42641829f8f.33.1776953066423; Thu, 23 Apr 2026 07:04:26 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43fe4dc24cfsm52984876f8f.16.2026.04.23.07.04.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2026 07:04:25 -0700 (PDT) Date: Thu, 23 Apr 2026 15:04:23 +0100 From: David Laight To: "David Hildenbrand (Arm)" Cc: Usama Arif , Alban Crequy , Andrew Morton , Christian Brauner , Lorenzo Stoakes , "Liam R . Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alban Crequy , Peter Xu , Willy Tarreau , linux-kselftest@vger.kernel.org, shuah@kernel.org Subject: Re: [PATCH v2 1/2] mm/process_vm_access: pidfd and nowait support for process_vm_readv/writev Message-ID: <20260423150423.1a428820@pumpkin> In-Reply-To: <62d88cde-efc0-48cb-be8d-813eda810343@kernel.org> References: <20260409142256.131676-1-usama.arif@linux.dev> <62d88cde-efc0-48cb-be8d-813eda810343@kernel.org> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 23 Apr 2026 14:52:26 +0200 "David Hildenbrand (Arm)" wrote: > >> > >> /* Get process information */ > >> - task = find_get_task_by_vpid(pid); > >> + if (flags & PROCESS_VM_PIDFD) > >> + task = pidfd_get_task(pid, &f_flags); > >> + else > >> + task = find_get_task_by_vpid(pid); > >> + > >> if (!task) { > >> rc = -ESRCH; > >> goto free_proc_pages; > > > > pidfd_get_task() returns ERR_PTR() on failure (e.g. ERR_PTR(-EBADF)), > > but the code checks "if (!task)" which only catches NULL. An invalid > > pidfd will cause mm_access() and put_task_struct() to dereference an > > error pointer, crashing the kernel. > > Yes. Should we add proper selftests that exercise these code paths? > Probably worth checking what happens when a 64bit process tries to read high addresses of a 32bit process. I remember trying to grok the way this code accessed the iov[] and failing to find the appropriate access_ok() for the accesses to the target process. David