From patchwork Mon Sep 2 05:31:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 13786721 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 1DC2DCA0ED3 for ; Mon, 2 Sep 2024 05:31:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9887E8D0076; Mon, 2 Sep 2024 01:31:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 937ED8D002D; Mon, 2 Sep 2024 01:31:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D83D8D0076; Mon, 2 Sep 2024 01:31:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 5632E8D002D for ; Mon, 2 Sep 2024 01:31:51 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A98D2C0349 for ; Mon, 2 Sep 2024 05:31:50 +0000 (UTC) X-FDA: 82518676380.22.6DBC93F Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) by imf20.hostedemail.com (Postfix) with ESMTP id EFD971C000C for ; Mon, 2 Sep 2024 05:31:48 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=osandov-com.20230601.gappssmtp.com header.s=20230601 header.b=IB43z43f; dmarc=none; spf=none (imf20.hostedemail.com: domain of osandov@osandov.com has no SPF policy when checking 209.85.210.53) smtp.mailfrom=osandov@osandov.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725255005; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=dcARxruAP0vzhVrIv4mZE+MUS7Q/ymIzQKM3BTvM2Fg=; b=syg96Osq89z3iaAF8YOh2slHftauB0R0rJ1UMdp6veJjDydU1/8ukfx6o6ils5Jb8kfVai naf4b4qwiB3RLSzLG4hgZ7xTDjtm9dAD39wEq7MlKvCCWjfl8edHJzv4UrgGch4K7ffJZ/ Rydej8aicy6h1enhk0Px2WPJ7Hrl314= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725255005; a=rsa-sha256; cv=none; b=dK8cilTAjUMc4FcLsoEyy2CAp8gFkLS+I3WZfEYR/OgdvG5CYGBR2BiVeyCidICOQ2Dws7 VW9z9vUvs8P1w9JEW2htSHhegHlbw0mkNGTth3qlQX/S3CXyZoQU4du44b3jk8iM5RcQV4 lrs2CqPrTEQoF9KtEcEQEI0YJQWpahY= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=osandov-com.20230601.gappssmtp.com header.s=20230601 header.b=IB43z43f; dmarc=none; spf=none (imf20.hostedemail.com: domain of osandov@osandov.com has no SPF policy when checking 209.85.210.53) smtp.mailfrom=osandov@osandov.com Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-70f6b9a1716so132149a34.1 for ; Sun, 01 Sep 2024 22:31:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20230601.gappssmtp.com; s=20230601; t=1725255107; x=1725859907; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=dcARxruAP0vzhVrIv4mZE+MUS7Q/ymIzQKM3BTvM2Fg=; b=IB43z43fVl9VYag88CcOOdnTktOu0ohIq1+RhuEFMxX7n6P8ZON8VFZyG7PgktCXYe mw9ARdY2OiP/rTuzOrM3l03Akin6OXWsGPbtaBuXbrcS92fXbg/X6G9eAaKbGJa6LtPj y/B2TYeg8z7GwdTa8act2LYdZoErOjNeam1RTorGO6rdZuUHMmHOMgdAHVVrSNDsw40a 3Dag/XffBP5njFHwPLChwivdKyi5qvvdsqj1s0myKwbYpZjIJ3mtoH35r7oJjzPeMagu KfKV5q4nqC/OxWfChhvGsfF27QrqKQGHi/PoSxfMKYKnK0uagRZBpB0RcUWrQzzpm1x3 JXQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725255107; x=1725859907; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dcARxruAP0vzhVrIv4mZE+MUS7Q/ymIzQKM3BTvM2Fg=; b=DejBERi/vB/Mx4E+ziMBOGfhJkWbnaVAByIH+2Ht6xU73qTANewipsPSs+zQpBfcRQ wOMKbKhRYr1NY0bzEMMYoVdWakzcSXlNe/lL029z1JO8dzphxwjwd3oCdlAmTv7j3h0P 1PiVPseV+mC5DGSKdALoheHXSw9XaPzVZy7fTBvD3FuEfkEPvz2VZVAg1GlS+PuUknc/ 8UGkuXLGunHazxWMJN3+0dJTxW3ZfQIDZAdSiQvSWyjT+bIIsv0NODGU+Tr3OQoVQJl4 HcqOKzvEMdHglEp/ekJjh51iG7VT1vyoOXcLmd85qewuo1kqNa/6v5aXhhGuRUMR+HS0 fS9A== X-Gm-Message-State: AOJu0YzPpoEGAiV4r3oyLUBN5ro1Pgjz27OGQ87aZ0zWFOJqtKHRaNEr DluPkBcm4RLNHLVdaX8HsCSsvc8wPdtN/yRlU6ocAGYfhsSvSnKFTALkpTeMprewLQZBCSeSbMe B X-Google-Smtp-Source: AGHT+IG4O9VSEnbCHyMlef62PC66eJmk+Wcfg7k+VoUwjggysZcp2Zp81AWYRWJzYn+qz65dfh/WPA== X-Received: by 2002:a05:6871:b09:b0:26c:78ce:b0cc with SMTP id 586e51a60fabf-277b0dd215bmr5158894fac.8.1725255107434; Sun, 01 Sep 2024 22:31:47 -0700 (PDT) Received: from telecaster.hsd1.wa.comcast.net ([2601:602:8980:9170::901f]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e55a692fsm6076279b3a.60.2024.09.01.22.31.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Sep 2024 22:31:46 -0700 (PDT) From: Omar Sandoval To: linux-mm@kvack.org, Andrew Morton Cc: Christoph Hellwig , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-um@lists.infradead.org, kernel-team@fb.com Subject: [PATCH 0/2] mm: make copy_to_kernel_nofault() not fault on user addresses Date: Sun, 1 Sep 2024 22:31:27 -0700 Message-ID: X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: EFD971C000C X-Stat-Signature: inmycrbm5rimakjfkq79iueig8hwu1sw X-Rspam-User: X-HE-Tag: 1725255108-387021 X-HE-Meta: U2FsdGVkX199dqliPi2zp7v0Rddw1o8fF6tmbf9n7xZ3cl2gnRMkFUMob7koSEStgwybO95kCpNGwBB0rTqNJsjGmfTZ0d3TYfKN9VCKb3GMX56zyrvd8bL7r16xh3AS6sFTipiZMZhp4oGq9y6ME1zkIZcJWHys+ZRmzuyieelFFu3ToVI5Js2rb/dF1eExWJ26Gqg/IA6vfUk+LhEJ8ei5d1Lr2nVl7Aog15fCef25EU+auagfRxU2BU+UdCD2N9YMgon40uY/3dESbqeGs2/LPQXWZ4doV4VHeTAl8oYJOMzOvfsw07++KIurvt5vOlVnCi1PYIgG6SP4XieZ8THRRsbS2JKLxH/c7y/H55THttKitUaQP0okCPHHrVx8XQaeEMlwLmzu7TJlNWoE9ZNiKgks3S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org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Omar Sandoval Hi, I hit a case where copy_to_kernel_nofault() will fault (lol): if the destination address is in userspace and x86 Supervisor Mode Access Prevention is enabled. Patch 2 has the details and the fix. Patch 1 renames a helper function so that its use in patch 2 makes more sense. If the rename is too intrusive, I can drop it. Thanks, Omar Omar Sandoval (2): mm: rename copy_from_kernel_nofault_allowed() to copy_kernel_nofault_allowed() mm: make copy_to_kernel_nofault() not fault on user addresses arch/arm/mm/fault.c | 2 +- arch/loongarch/mm/maccess.c | 2 +- arch/mips/mm/maccess.c | 2 +- arch/parisc/lib/memcpy.c | 2 +- arch/powerpc/mm/maccess.c | 2 +- arch/um/kernel/maccess.c | 2 +- arch/x86/mm/maccess.c | 4 ++-- include/linux/uaccess.h | 2 +- mm/maccess.c | 10 ++++++---- 9 files changed, 15 insertions(+), 13 deletions(-)