From nobody Mon Jun 8 08:28:40 2026 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 69167326D51 for ; Thu, 4 Jun 2026 15:58:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780588704; cv=none; b=XBxUGCnuDJKXxVGZeflr0m7WzbK6L1CYpNXdSNuElFG/X4es7TTyCI0fhQS+hUPgDp2pehcrRus+5pHoFRJEakUryOrG6O1omkpQytNKdTOrNfXB3J2H/FdLGa79ikYetD2VQy6WgB83mlh7rV/wGwEeBHZHG9GDsyYj8Pjr1NE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780588704; c=relaxed/simple; bh=CG4tYKE/ZDtEvhTjWK4OQ+Pk+mMRQbkaM8xxSMWv8lU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=QwGtV6k+8Lcimcyv0c+vuby25vZNQ7s2Uui8hSA6b8IT2bUarCFicQdcC0cvsKoRH5vwN+mzXHgn2Al1j5wkjZG1SCrNj+RPxSpwS788YqP8JRn9jC23V8qpIH+vwbcD1yCrVPBRFlViDGuI2ME4uqBTavt37Il/AWm+M8Log8s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=fJqRJg3l; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fJqRJg3l" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-490b23c828aso72815e9.1 for ; Thu, 04 Jun 2026 08:58:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780588702; x=1781193502; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Pqw6xFqYHfbtPS2lscmy3UHUr79W7GtUNGneEf+7Bf4=; b=fJqRJg3l1bU+Nf4xgAugLcVG/ajXDWvTJ1gKmne2CWgvXFNwtqpCKgV9vU0w2fGhZR fsMwh6btn9HKQMABdn4pRJS7EPi3eyBpjEdbcoFtCr9yCIP6CjCBF4mtuqWDK5uIbOGy vee3rDhJzW1oFmFS4LtYIoO11F++5G4I/S5BdEpS7v9pTw6Do/gTOxRlek/4Q6W4tnEl RDgz/t/bX5p+gGKa04KtK02AEITk2ptbpxCRF8kQ5dEcREKY2o3Op7cnLNUVwZ6kiTPa RyP1wp6LwDWDOlYTuheo0B1iwk2fTdjlbjkNWyKIpjhozqpSUbCxHzs6B55b5uyT/T5E ftQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780588702; x=1781193502; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Pqw6xFqYHfbtPS2lscmy3UHUr79W7GtUNGneEf+7Bf4=; b=H8g9744ViiA0nIysh60K8/6W5SJaWQJm/1QR+x7YQuUDM+eRjp+IROFxIQkXbSWkzv dtqkkjguC9ww4Mnqx8S10ST6kTFdoP529BMWV5ie2o5NsrCp2MxYwbOWHPqGrJMaI8cb G5oW01VKgX8lfPu0sHGzgfOA08Lndi4o0Wsdnc5VQMDaOcOrLXOPGgXEthONAKRl2b8Z 45KK5ARDybCbHbZFvLTZy9NGTuXmufhPUma/KLvPCg3aAFuMVAa4VZdqhlo8ijiIPZPf CtgIMZzhQ9pLgDnu/nQUsMg5Qv3B165z+vsY9ZgmDYnuvqzjfOre6qXsZ25Zwa/uvfk8 GQCg== X-Forwarded-Encrypted: i=1; AFNElJ8czKfr+BI4X1xzy8HpVq+hMXOFpoV5cGW/UKaEAB4sooa1/shVrVAOxrrjMbZf2R/2Kq4hqXxH+N49hdE=@vger.kernel.org X-Gm-Message-State: AOJu0YwTRKe4h2fb3rPPx5TGZkawuao3qYQAfJXelUJIP2KiWTu31c6C UtCnQ62iDSODLtueaZ7lExgW4HltnEECwCtzgmi1wrVMH8+r99W3U97rWV3Jh1ZF3Q== X-Gm-Gg: Acq92OFszy774JXtiqwOy0tZ8EZ/xTSqIxjFlP6tUfZS3FH8yQ98derw6rhnzNIo5rN I/ubHPbQg8mEkXcHrW4+Bxj4zSAW5ebUavCnZ9kq0V8K3Wyet/9Ui4qRV4F5pIrI7Y0kzZuItRF H2F6ptBvNfanSG0rfzB/zRVtCXoEJfZ5QP3W9fO96liOFfisx9XuKNfUXcvfjye55woqQatul/q 4KgCczmbUzi9p7k7onfAXhMCzu1E51am7iQw7cjNE9I4l3SecUhzodcSUP30Ur1GfWpBzY78TDb p9nncu6V2uCHgGbn/zj1sHZoXFKc6cZ0T1ggQ7i3Qfgy+62h43UWjb2ei24/QifzlINYq0xD83N +fUdCQl5vcx51JvczbZgvDz+kJ91U05o2FmYy/JIkNBe70g/xfAtB17ELySfXWmEdEyrPrTeLWe e9xJlZO/TCFPk1tIRWEmG1MHWVG90WOcSBe/OPiDlTTHX2/2wtdQEUiqPDRLPWaA== X-Received: by 2002:a05:600c:68d5:b0:48a:623c:8859 with SMTP id 5b1f17b1804b1-490bd7e523bmr950095e9.7.1780588701225; Thu, 04 Jun 2026 08:58:21 -0700 (PDT) Received: from localhost ([2a00:79e0:288a:8:5de2:6c77:4bc3:b0dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f344762sm19004407f8f.23.2026.06.04.08.58.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 08:58:20 -0700 (PDT) From: Jann Horn To: Alexander Viro , Christian Brauner Cc: Jan Kara , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] fixup! proc: protect ptrace_may_access() with exec_update_lock (part 1) Date: Thu, 4 Jun 2026 17:58:06 +0200 Message-ID: <20260604155806.1402880-1-jannh@google.com> X-Mailer: git-send-email 2.54.0.1032.g2f8565e1d1-goog Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" fix two test breakages in tools/testing/selftests/proc/read.c: - The test requires that readdir() on directories in procfs does not fail when running as root. Restore the previous behavior where /proc/$pid/map_files/ simply returns an empty directory if the process has no MM. - The test requires that any directory in procfs has "." and ".." entries. Restore the previous behavior where, even if a task has no MM, /proc/$pid/map_files/ still has "." and ".." entries. (This now differs from previous behavior in that even if the caller does not have permission, they still see "." and ".." entries; recreating the old behavior exactly would make this code unnecessarily complex.) Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202606021924.b6d8a0c2-lkp@intel.com Signed-off-by: Jann Horn --- fs/proc/base.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index ef2f59461374..5042f14d24f3 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2399,16 +2399,19 @@ proc_map_files_readdir(struct file *file, struct di= r_context *ctx) if (!task) goto out; =20 + ret =3D 0; + if (!dir_emit_dots(file, ctx)) + goto out_put_task; + mm =3D mm_access(task, PTRACE_MODE_READ_FSCREDS); if (IS_ERR(mm)) { ret =3D PTR_ERR(mm); + /* if the task has no mm, the directory should just be empty */ + if (ret =3D=3D -ESRCH) + ret =3D 0; goto out_put_task; } =20 - ret =3D 0; - if (!dir_emit_dots(file, ctx)) - goto out_put_mm; - ret =3D mmap_read_lock_killable(mm); if (ret) goto out_put_mm; base-commit: 5200f5f493f79f14bbdc349e402a40dfb32f23c8 prerequisite-patch-id: 0000000000000000000000000000000000000000 prerequisite-patch-id: 7c4ef33778ceb9b6e644d78c5be66b99c0c77d51 prerequisite-patch-id: bd555aff354c96a946f72e56d5d55eecc33a7b47 --=20 2.54.0.1032.g2f8565e1d1-goog