Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5550746pxb; Tue, 16 Feb 2021 01:06:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJyak80ZDsbyt0mdYHfEmx39uRssRVUu3hGdHF6agj1oWtM4a2VmgeKFo3PEd55363T1WGMP X-Received: by 2002:a17:907:7781:: with SMTP id ky1mr19081688ejc.255.1613466382562; Tue, 16 Feb 2021 01:06:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613466382; cv=none; d=google.com; s=arc-20160816; b=z6GhvI6XsFpIeeAmF+pihKYElLRfFld4ykR51dF9n3sc9w8W35w6BSgwZ32nhU/GEU YKUw9BGzMPjVaSknnTeqo3cN09E/ZGhQweoFojgZDQklGfl02t0zS2jiylFBkEtTsOni HuKvEIzsxyTIZRt9OCTvTksDr/4NlPDUQvtU4u0O/ocjovX+Yii5XDj1sHuGM9Ka0zjt 0OqAelQOnIoXPYM68DSBk02iDuEJkuNFyqgl0O+rXetF4yuuqWW5AsUTXtstc6g7sJ+k q7+njigTsbctdmGKEI7ElvqTzXYnoSLs7vKF7yj6SUki5hVPI4F5Zcv0x/wGOocskb4k ph7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=mDlPxT1oYOHjNwYS05Ap/lIR6S8YHeXV+kKzkitrMDQ=; b=Cu92QyQwAdN97arNNXuZ2ZW8SIvwEnmaygjqmGN9C+2jD7bkU0oSP8eAz4+PWL7sRY dMVNxtjj+fo48ONLJ+9Vpl9Rx6fxTi4dSphgk9uxdOVMfmAtullj+BhNwi8E1xSXSlnJ OfuJ24N3dSm5bjoPmBvnse1hrJtTuSWvdy2UZazk7OI2fqibmFEcMWDMbWANxQeuGk4l 8BfHgeQ62aP9mSKlXiWdpn3E22R6iSp8m4c+o8XwicvR+uNA9DkYMJKqenebhR+p3l2Q jWVgKqGZCxWaG2vyCrOlRCadLmiFswrQGosErtF34WRqprQfXAqMPI7/TFo8rbi7hhaq mQXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=P84QBlrD; 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 s22si13387415ejb.250.2021.02.16.01.05.58; Tue, 16 Feb 2021 01:06:22 -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=@ffwll.ch header.s=google header.b=P84QBlrD; 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 S229830AbhBPJFP (ORCPT + 99 others); Tue, 16 Feb 2021 04:05:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229694AbhBPJDh (ORCPT ); Tue, 16 Feb 2021 04:03:37 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7F79C061574 for ; Tue, 16 Feb 2021 01:02:56 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id r21so11989175wrr.9 for ; Tue, 16 Feb 2021 01:02:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=mDlPxT1oYOHjNwYS05Ap/lIR6S8YHeXV+kKzkitrMDQ=; b=P84QBlrDHp1+oLkPR3XS9Hib/6uzVaxYNFJgJqenGr84ms/syz53/GC7p+NbOLrGj+ gjAYBIMdPYfda69ID5AD2eRkuVj2B1WrQIcTUVNxZ1uVa30yJDdPjQOyIv8nhnYY+RKp Ih5r5D2HlnPd5gTYe/+bk651yaER9bk3+HbG4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=mDlPxT1oYOHjNwYS05Ap/lIR6S8YHeXV+kKzkitrMDQ=; b=FrLSpzYKOM50/DVv5CWgafzu349h/NJ7AGI32Bb0xqGP/KGBlo/71cAcymNHUBAwcN 6jBNIHG4Oh5+HSB8EUne7sBHS5GYpD0fv5ENLtk7QY88WcJ8W9NovZWPx8WRGMfe2U+F tfepgMpkAAPB4PllmncnEc8Jj7UzSHNxVPiUDnvacyXNoExiFqZamMczNSpuG3N4hkvv mZ8rOhh4gYl5uYL8juFl2zEpAj46bKneGxC5db9yhDhD6Cfrz/Vv7D9W6rvGxtYOc9a5 8++lEI6kkuZzbxGhg1FSeQWTwFGCVYlZKPF1tBbjsTcgUUyLk8ikgp1t8cfa8rQctq2U b3SQ== X-Gm-Message-State: AOAM530twg4x8veor6lnhWKsabH6+AXscDiSGWjSEm9QGRw0eMNJcrBL 8BXXgZwtkrYQYdy9CLutaKZSxg== X-Received: by 2002:adf:808c:: with SMTP id 12mr22608224wrl.139.1613466175552; Tue, 16 Feb 2021 01:02:55 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id n66sm2511069wmn.25.2021.02.16.01.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Feb 2021 01:02:54 -0800 (PST) Date: Tue, 16 Feb 2021 10:02:52 +0100 From: Daniel Vetter To: Kees Cook Cc: Chris Wilson , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Andy Lutomirski , Will Drewry , Andrew Morton , Dave Airlie , Daniel Vetter , Lucas Stach , Rasmus Villemoes , Cyrill Gorcunov , stable@vger.kernel.org, Daniel Vetter Subject: Re: [PATCH v3] kcmp: Support selection of SYS_kcmp without CHECKPOINT_RESTORE Message-ID: Mail-Followup-To: Kees Cook , Chris Wilson , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Andy Lutomirski , Will Drewry , Andrew Morton , Dave Airlie , Lucas Stach , Rasmus Villemoes , Cyrill Gorcunov , stable@vger.kernel.org References: <20210205163752.11932-1-chris@chris-wilson.co.uk> <20210205220012.1983-1-chris@chris-wilson.co.uk> <202102081411.73A442F17@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202102081411.73A442F17@keescook> X-Operating-System: Linux phenom 5.7.0-1-amd64 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 08, 2021 at 02:12:00PM -0800, Kees Cook wrote: > On Fri, Feb 05, 2021 at 10:00:12PM +0000, Chris Wilson wrote: > > 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. > > > > References: https://gitlab.freedesktop.org/drm/intel/-/issues/3046 > > Signed-off-by: Chris Wilson > > Thanks! > > Reviewed-by: Kees Cook Thanks for reviews&patch, I stuffed it into a topic branch and plan to send it to Linus later this week. Cheers, Daniel > > -Kees > > > 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 > > > > --- > > v2: > > - Default n. > > - Borrrow help message from man kcmp. > > - Export get_epoll_tfile_raw_ptr() for CONFIG_KCMP > > v3: > > - Select KCMP for CONFIG_DRM > > --- > > 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(-) > > > > diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig > > index 0973f408d75f..af6c6d214d91 100644 > > --- 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 > > 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..9cc7436b2f73 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,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 > > 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 > > > > -- > Kees Cook -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch