Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp554690pxb; Wed, 3 Mar 2021 09:26:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwVDoqwO/XToOBA4VBeBKscBJA6gsv7YkzvrnmW49gHClV42FXrqoUcAbN9j44RN4IPAJ7B X-Received: by 2002:a50:bec3:: with SMTP id e3mr368323edk.290.1614792405781; Wed, 03 Mar 2021 09:26:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614792405; cv=none; d=google.com; s=arc-20160816; b=O/K/hoPIusHrNE1g2bA7vjKdBo5DXsrhfAo+iFUM7h8y/xq5qrAc5QakLuWjZVPB45 bRei1UxpcKEPGiDrMHHv3OTe2+xtE18ZQtbBmX+VYbGbUSCM3NixTV5/23UnAqbl3zII SbUgzMhTwC1hhKwjnRLf0RyVk2NgrcvaS9p8MSiM4gvR5DWaQ+EhfuVfbzRzPgd0LAfw 3jpUVjFwv3WEpat6jZOnT7LE7J57sMrStSlLQALSxHv9YsJdmEk8EDLfxcOH2XAtaZa2 seqtxyW57o425nkOR0gdEC9pfSl3KCQuDoHVxrUXmLVNkYVPjiR7Vi54mccfueEuFKWJ Aa2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SRMlZmb9bJ9j/EizoyR3S+werUmoFXuZZOXgPrvfO7M=; b=LIHjCeoje+CzDJtJAKZn9dRaNxqIOpRiOXypEJv1dhwj2IuB4P65hJDNQpp0QNtmAE NOGN/TZOOzUa/b8MYjc0t5fDK93CEKJ+DzPFwcOREfvz3oh0EBflNKs2cDpVjt3/UK8K Lctduj9hLQ0QipKKNAux2UfZGCC967l/0RRAzTfbsgTWD3jXq/gpHZ0vBG8QHitcTN3g CpBPFgL2hpxiGYC+/WOiKinc00Mb94Oi+Hc5dyLQDRmf2TkOuCw15yCw8+tmY6sTW71R j3QRbbfEW0q28JZmThpGWNdGTGDfnwy/AOcaXYQUEA1gT+WpWbcdR/A1DgnAg6wJ5gYl nf1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iTNS8qgg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q17si15587543ejy.390.2021.03.03.09.25.40; Wed, 03 Mar 2021 09:26:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iTNS8qgg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377099AbhCBApl (ORCPT + 99 others); Mon, 1 Mar 2021 19:45:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:51300 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240502AbhCASjS (ORCPT ); Mon, 1 Mar 2021 13:39:18 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 211356508F; Mon, 1 Mar 2021 17:31:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614619916; bh=xl/RzlTfeoa9gNbStTQWMWCscnIf9VS68Kbwwf9cTas=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iTNS8qgg4lFLQBF9LYscK9oe8xnDBVhWhHfI9VCRst1IIZu0MIEOwzgKZ/HOMxGgR unzlhj8zyTq8HFZnM8krZc888oDTGYUpSWVS/YAEbWWpIZrDHF6bHYbIPg8VCdjY+g AFzouaTnMtOHn/MsyUqarxSlv5kPf1jTdictNE1o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Wilson , Kees Cook , Andy Lutomirski , Will Drewry , Andrew Morton , Dave Airlie , Daniel Vetter , Lucas Stach , Rasmus Villemoes , Cyrill Gorcunov , Thomas Zimmermann , Daniel Vetter Subject: [PATCH 5.10 620/663] kcmp: Support selection of SYS_kcmp without CHECKPOINT_RESTORE Date: Mon, 1 Mar 2021 17:14:28 +0100 Message-Id: <20210301161212.521569141@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chris Wilson commit bfe3911a91047557eb0e620f95a370aee6a248c7 upstream. Userspace has discovered the functionality offered by SYS_kcmp and has started to depend upon it. In particular, Mesa uses SYS_kcmp for os_same_file_description() in order to identify when two fd (e.g. device or dmabuf) point to the same struct file. Since they depend on it for core functionality, lift SYS_kcmp out of the non-default CONFIG_CHECKPOINT_RESTORE into the selectable syscall category. Rasmus Villemoes also pointed out that systemd uses SYS_kcmp to deduplicate the per-service file descriptor store. Note that some distributions such as Ubuntu are already enabling CHECKPOINT_RESTORE in their configs and so, by extension, SYS_kcmp. Signed-off-by: Chris Wilson Cc: Kees Cook Cc: Andy Lutomirski Cc: Will Drewry Cc: Andrew Morton Cc: Dave Airlie Cc: Daniel Vetter Cc: Lucas Stach Cc: Rasmus Villemoes Cc: Cyrill Gorcunov Cc: stable@vger.kernel.org Acked-by: Daniel Vetter # DRM depends on kcmp Acked-by: Rasmus Villemoes # systemd uses kcmp Reviewed-by: Cyrill Gorcunov Reviewed-by: Kees Cook Acked-by: Thomas Zimmermann Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20210205220012.1983-1-chris@chris-wilson.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/Kconfig | 3 +++ fs/eventpoll.c | 4 ++-- include/linux/eventpoll.h | 2 +- init/Kconfig | 11 +++++++++++ kernel/Makefile | 2 +- tools/testing/selftests/seccomp/seccomp_bpf.c | 2 +- 6 files changed, 19 insertions(+), 5 deletions(-) --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -15,6 +15,9 @@ menuconfig DRM select I2C_ALGOBIT select DMA_SHARED_BUFFER select SYNC_FILE +# gallium uses SYS_kcmp for os_same_file_description() to de-duplicate +# device and dmabuf fd. Let's make sure that is available for our userspace. + select KCMP help Kernel-level support for the Direct Rendering Infrastructure (DRI) introduced in XFree86 4.0. If you say Y here, you need to select --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1062,7 +1062,7 @@ static struct epitem *ep_find(struct eve return epir; } -#ifdef CONFIG_CHECKPOINT_RESTORE +#ifdef CONFIG_KCMP static struct epitem *ep_find_tfd(struct eventpoll *ep, int tfd, unsigned long toff) { struct rb_node *rbp; @@ -1104,7 +1104,7 @@ struct file *get_epoll_tfile_raw_ptr(str return file_raw; } -#endif /* CONFIG_CHECKPOINT_RESTORE */ +#endif /* CONFIG_KCMP */ /** * Adds a new entry to the tail of the list in a lockless way, i.e. --- a/include/linux/eventpoll.h +++ b/include/linux/eventpoll.h @@ -18,7 +18,7 @@ struct file; #ifdef CONFIG_EPOLL -#ifdef CONFIG_CHECKPOINT_RESTORE +#ifdef CONFIG_KCMP struct file *get_epoll_tfile_raw_ptr(struct file *file, int tfd, unsigned long toff); #endif --- a/init/Kconfig +++ b/init/Kconfig @@ -1194,6 +1194,7 @@ endif # NAMESPACES config CHECKPOINT_RESTORE bool "Checkpoint/restore support" select PROC_CHILDREN + select KCMP default n help Enables additional kernel features in a sake of checkpoint/restore. @@ -1737,6 +1738,16 @@ config ARCH_HAS_MEMBARRIER_CALLBACKS config ARCH_HAS_MEMBARRIER_SYNC_CORE bool +config KCMP + bool "Enable kcmp() system call" if EXPERT + help + Enable the kernel resource comparison system call. It provides + user-space with the ability to compare two processes to see if they + share a common resource, such as a file descriptor or even virtual + memory space. + + If unsure, say N. + config RSEQ bool "Enable rseq() system call" if EXPERT default y --- a/kernel/Makefile +++ b/kernel/Makefile @@ -48,7 +48,7 @@ obj-y += livepatch/ obj-y += dma/ obj-y += entry/ -obj-$(CONFIG_CHECKPOINT_RESTORE) += kcmp.o +obj-$(CONFIG_KCMP) += kcmp.o obj-$(CONFIG_FREEZER) += freezer.o obj-$(CONFIG_PROFILING) += profile.o obj-$(CONFIG_STACKTRACE) += stacktrace.o --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c @@ -315,7 +315,7 @@ TEST(kcmp) ret = __filecmp(getpid(), getpid(), 1, 1); EXPECT_EQ(ret, 0); if (ret != 0 && errno == ENOSYS) - SKIP(return, "Kernel does not support kcmp() (missing CONFIG_CHECKPOINT_RESTORE?)"); + SKIP(return, "Kernel does not support kcmp() (missing CONFIG_KCMP?)"); } TEST(mode_strict_support)