From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 91B2C2F691D for ; Sat, 20 Dec 2025 21:56:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766267784; cv=none; b=c3QLoIKTtWhIJkI2FWh/Gj55tYsnyK7eIjgdeABWYW4R8oOg1m3S5ZNmSauB9TJrQpSnqVrxH1BRrayCysq6cqXsrsn5eVZmR+lrM5qkpsYQG3U4VYHE1cviVgMiURmMC5UKuawy90QIgT+fMEZtU3QZ7UT0YAnfkMr5y+EEjY4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766267784; c=relaxed/simple; bh=sHVnGF8w99CbKUHDouBCnJh1zjx1SCoXsqkPjfXaHkw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=tN5mCV0/tvFWiy7oKEEKKZDVdhJhGzLw6wFKz0ei8p/rvFrpfGvoRruBQ4mjP2F1d8QHI+tNFDMLY6TIt+EqN4pfiTQ5o5A/w8976Lg8VOcZTPMyhEgtUfcjN/+fTcFMjXcFVNZEcdKaRqswGh75ZxpDar0TqBOoZgIcj8iplEY= 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=GNhnpsPk; arc=none smtp.client-ip=209.85.128.43 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="GNhnpsPk" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4777771ed1aso20011035e9.2 for ; Sat, 20 Dec 2025 13:56:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766267781; x=1766872581; 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=kU7TljOaj/rJDfsrzTxuCqZaukE+1I/AVvBEStZ/skI=; b=GNhnpsPkokTb8HVIp8srWBe/ZhQ/x8YzLSZRMqn4Ek9U4Ssdjq0/NePP2InbZki4cP A3L5hzNRUCq10J6TxMBL90CWlQZt91QA+oD2aJ5UbB/f7SaoaHOAXkdwUpxjQJRm2z+s nzn8hcNNNZy9UxCBmDNvpOTzFwY0W8rfLbf/Po6PaTdpibA2wnSPkzQgsi8Pjjkoh6c1 T+ubwoRhdExMrD7/yu6hw5yhdmi5syBmKAryMjuLTZxedRA/suXL8NUycp51iCNEtVJ9 3smJ72egntLxEu3mFQlxearGhNZuAeB50OBZKsXMrNlb33C2k6FPZ2E+vX+ROLjXRWos jFdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766267781; x=1766872581; 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=kU7TljOaj/rJDfsrzTxuCqZaukE+1I/AVvBEStZ/skI=; b=dAVu5l4llBOR0ayIU9lTYUqHgnqYfEF77FckDlmbWzkyalHadKFb+KakKgzvjByeGP J9ihZxhuQDLB+3zJFyyCykuBlXcrsYCMqFgdc2xQj5KBcQKXgCAks0HHEJGPljATIgRm cXGHb8fXexmnPTTNWK04eKukUuxgngNU0/syv7lRerJmyN4tDqrMgkUEHnGvwk3VHRp+ y6jaFw9WOXWgVsSorcfA+IPNxVnVtumvB6wiAkLNt0WR4hBaqN8SUAeGewfJQX2Gl0nm d3ekJqD/QOVcyP0Uy4h76SBLm483KA+vj57qVvcdVXVE5nBZGs9zA35+//r2lUcjFJo4 Js0A== X-Forwarded-Encrypted: i=1; AJvYcCU2Y6SkebhHKYtagCg5yT47hxOISMbLQ1H00rUESSmQGrskVX4hAvKkbKrC4JXk/bLrSuH/jHrPS1c2qwI=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5iBJl5zyj70fGzi3JhBDXtNu/SqHvpVrlbi7lVFmK6EiHcxMz ui9GMZGtK3qJcgLO4rVKeP8q1MHU6hTBYNjHqAY+WtuDOKXywCotogOJ X-Gm-Gg: AY/fxX4m5C9fZIx82YGik926YbtUk8dEvLS+83ApCiIv46VkXQng0c8ZQb0IWaprtsg YQpdFo24Eualjdp3UPLD4A8XmkrVPA7hEmhML65ZGPBNJBuvWNWv0kph0M3OnFyd8o7F+jYu55y zD9OkzhoRVZa9mvbc7Pd41CuP1+iaPmyCr1ylwF6BipQvput04Sq/5OjnT/MCOMAelkiIO4xqcs qMVpmQ36VlWImlm+4XF6wc/qwIDOmYbSfKFRpvwHbnczT84dXKRL3Rf5nneU9M/zlc0YLU/KUuF gdg+zVQ1BS5DIWUcX69TE+r8cu8ylTv3bjZy1JflFeDZJTCYtcP/RHVdG9C8EXBry3Ip/zVynfq lHn+nxfHOPo1aVXV8upS+CYhnqgYHmqahxj8byCJvFKchG+bPN2/rbIRd08zu4dw8cvNeN7rgG2 g1k6ahK/WCVb6EGAT+7WK0wIoynBm8g0D48oB2fgQOcpbXg387x9phJmz0AkLon9OSqQZGjbQV X-Google-Smtp-Source: AGHT+IEJeXPLqv7AYotrh6yw4lMZvA5C0hdQ8RuVhklNP76LTPI9gccRQiSzT2Z6Obw7W5nRosD3jw== X-Received: by 2002:a5d:4a4d:0:b0:432:5c43:76 with SMTP id ffacd0b85a97d-4325c4302eamr1583901f8f.39.1766267780395; Sat, 20 Dec 2025 13:56:20 -0800 (PST) Received: from snowdrop.snailnet.com (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4325c052d34sm3601755f8f.25.2025.12.20.13.56.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Dec 2025 13:56:20 -0800 (PST) From: david.laight.linux@gmail.com To: Thomas Gleixner , Linus Torvalds , Peter Zijlstra , Mathieu Desnoyers , Kees Cook , linux-kernel@vger.kernel.org, akpm@linux-foundation.org, Al Viro Cc: David Laight Subject: [PATCH 0/5] uaccess: Updates to scoped_user_access() Date: Sat, 20 Dec 2025 21:56:03 +0000 Message-Id: <20251220215608.434614-1-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: David Laight Converting kernel/signal.c to use scoped_user_access() had compilation warnings because some of the pointers are 'pointer to const'. This is fixed in patch 1. Patches 2 and 3 factor out the 'autoterminating nested for loops'. I'm sure there'll be a 'bikeshed' discussion about the names. I think the two 'typeof(uptr)' could be 'auto', compiles for me but IIRC there are issues with old compilers. Patch 4 stops warnings from -Wshadow (enabled by W=2). I did think about making the _diag_xxx conditional on a W=2 build, but since the pre-processor just emits #pragma lines and they are smaller that the for() loop it doesn't seem worth while. Patch 5 is the change to signal.c that prompted patch 1. The generated code looks fine, but I've not tested it. Most of the changes are to 'compat' code - so are probably not usually performance critical. IIRC the non-compat code uses copy_to/from_user() for the structures so is probably slower than the compat code's member by member copy. David Laight (5): uaccess: Fix scoped_user_read_access() for 'pointer to const' compiler.h: Add generic support for 'autoterminating nested for() loops' uaccess.h: Use with() and and_with() in __scoped_user_access() uaccess: Disable -Wshadow in __scoped_user_access() signal: Use scoped_user_access() instead of __put/get_user() include/linux/compiler.h | 26 +++++++++++++++ include/linux/uaccess.h | 32 +++++++++--------- kernel/signal.c | 72 +++++++++++++++++++++++----------------- 3 files changed, 84 insertions(+), 46 deletions(-) -- 2.39.5