Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2268469pxb; Fri, 5 Feb 2021 13:18:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+v6rQx7DOVphYj0cWHwCXtrTi7x2nWGHaHMbO/DXNQl8YDKC67SnamuoShc3PYXL9KF1w X-Received: by 2002:a17:906:34c3:: with SMTP id h3mr5821481ejb.132.1612559908389; Fri, 05 Feb 2021 13:18:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612559908; cv=none; d=google.com; s=arc-20160816; b=qCQcCrP7WxD4Oi0q9pJuaYdw6keRpnyI+vUs1B5Nh1XuwnnWqSXgDxTmJnVbvyuqH7 UQO+8GVsQSUZAkyjnFAQZ/thzLb5UL8s7fxaNBAIQLvlHFVFJL+7PSYTzA0iKvgwNzW9 z9cK6RQgtLIiTVdPBpc4Fsmw6fPRh98mReVFeBdOYnaqcFLpWmJvnM2/9JBTa+Vnq8w8 Ib3Dw3p8QOdR3z2QkHKhnrwnfhxxwj8ZUkNvj9Evce6tzD2XX3dr9hBVmcJ6XTRI8jLV 8PdPH4yJ+mCBAg+Aqr5UPiKRvCBe40orwsxOYMQOT7XKQDaFcYuD5xNimvqha66RWqM2 mo0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:date:to:cc:from:subject :references:in-reply-to:content-transfer-encoding:mime-version; bh=pBwn9Uf0XIunfVp9IjRu6mnHubac/8eFntKlqD3wQfA=; b=QHUjRPbgHiZvM3VT2vOOKY0GLu8cxFBQ8GYsK2gEOnl53kIP+K0+Q8Ay2aBM6C7sgE rUU+DH4kodSWDpQML9PedZQNfYpROB3BH8v6c+cSkrssw8fN4PQKNVpyPjYxxdxZwnac ArcEGAewJeUHdbnh82zoz3qVQ1pf8WZV0x0YMVF2sneGlGYh3xqig9MYYNYfqolP13kf z9rh6AXMFO9IXwWcex25hXxNtEt2FK4gZt/nLD5Kus2HMuKeqlBQLwOKgLnKSsAWYVrc 6rNf/e1MylaKgi1PFHWGZkzciYxJUjBYUQOAKVErNGJytqKg4p7o2VLYZp8jTcOtrbpK fZ0Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bd14si6224552edb.587.2021.02.05.13.18.04; Fri, 05 Feb 2021 13:18:28 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231524AbhBEVRT convert rfc822-to-8bit (ORCPT + 99 others); Fri, 5 Feb 2021 16:17:19 -0500 Received: from mail.fireflyinternet.com ([77.68.26.236]:58674 "EHLO fireflyinternet.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S232789AbhBEVQq (ORCPT ); Fri, 5 Feb 2021 16:16:46 -0500 X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.69.177; Received: from localhost (unverified [78.156.69.177]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP (TLS) id 23802939-1500050 for multiple; Fri, 05 Feb 2021 21:16:02 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT In-Reply-To: <20210205210610.29837-1-chris@chris-wilson.co.uk> References: <20210205163752.11932-1-chris@chris-wilson.co.uk> <20210205210610.29837-1-chris@chris-wilson.co.uk> Subject: Re: [PATCH v2] kernel: Expose SYS_kcmp by default From: Chris Wilson Cc: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Kees Cook , Andy Lutomirski , Will Drewry , Andrew Morton , Dave Airlie , Daniel Vetter , Lucas Stach , Daniel Vetter To: linux-kernel@vger.kernel.org Date: Fri, 05 Feb 2021 21:16:01 +0000 Message-ID: <161255976138.12021.9385501710085642237@build.alporthouse.com> User-Agent: alot/0.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The subject should of course be changed, as it is no longer being enabled by default. Something like kcmp: Support selection of SYS_kcmp without CHECKPOINT_RESTORE Quoting Chris Wilson (2021-02-05 21:06:10) > 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. > > Note that some distributions such as Ubuntu are already enabling > CHECKPOINT_RESTORE in their configs and so, by extension, SYS_kcmp. > > References: https://gitlab.freedesktop.org/drm/intel/-/issues/3046 > 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 > Acked-by: Daniel Vetter # DRM depends on SYS_kcmp > > --- > v2: > - Default n. > - Borrrow help message from man kcmp. > - Export get_epoll_tfile_raw_ptr() for CONFIG_KCMP > --- > fs/eventpoll.c | 4 ++-- > include/linux/eventpoll.h | 2 +- > init/Kconfig | 12 ++++++++++++ > kernel/Makefile | 2 +- > tools/testing/selftests/seccomp/seccomp_bpf.c | 2 +- > 5 files changed, 17 insertions(+), 5 deletions(-) > > diff --git a/fs/eventpoll.c b/fs/eventpoll.c > index a829af074eb5..3196474cbe24 100644 > --- a/fs/eventpoll.c > +++ b/fs/eventpoll.c > @@ -979,7 +979,7 @@ static struct epitem *ep_find(struct eventpoll *ep, struct file *file, int fd) > 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; > @@ -1021,7 +1021,7 @@ struct file *get_epoll_tfile_raw_ptr(struct file *file, int tfd, > > 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. > diff --git a/include/linux/eventpoll.h b/include/linux/eventpoll.h > index 0350393465d4..593322c946e6 100644 > --- 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 > > diff --git a/init/Kconfig b/init/Kconfig > index b77c60f8b963..1b75141bc18b 100644 > --- 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,17 @@ config ARCH_HAS_MEMBARRIER_CALLBACKS > config ARCH_HAS_MEMBARRIER_SYNC_CORE > bool > > +config KCMP > + bool "Enable kcmp() system call" if EXPERT > + default n > + 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 > diff --git a/kernel/Makefile b/kernel/Makefile > index aa7368c7eabf..320f1f3941b7 100644 > --- a/kernel/Makefile > +++ b/kernel/Makefile > @@ -51,7 +51,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 > diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c > index 26c72f2b61b1..1b6c7d33c4ff 100644 > --- 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) > -- > 2.20.1 >