Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2174218pxb; Fri, 5 Feb 2021 10:40:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyWzfS6ulOb3krCYg5cNUjzhKmHqH4O0Nz/Ax8ASxqd92eAeXpOOgsWVb2Qp+s/L+UlsbeA X-Received: by 2002:a05:6402:34c5:: with SMTP id w5mr4962321edc.65.1612550446503; Fri, 05 Feb 2021 10:40:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612550446; cv=none; d=google.com; s=arc-20160816; b=FYOLWU8/G2Mg+XzyNVnJuvHmuyZsOfwetdUL0e/fRRv/HhzjkELiIOh9hZZiJMXZ3J pz7naWrb/xCzTt/ql79vzlOJ/w9bOHzc+kljUTC0lapGwvqYgreb1RGsVRGkSaHxxZSM /OphsYI0C5ZC/as+WPkc9SrH+7gE8OtNWn32Y773dmU/V1R2dEcFkWslxEP7rk5HccRF QeSZmBx8ukY0n96JmEU/b0EmgzuwXdutjw6kMolUfZjjG64+IeQ6sve9HwxtzFmtHMz/ PtcTPgkNAHNMfKZXbJ3BcbewwdhOlTfxiyc95lm2z1n7vJjN0VDZfSQEMXzrwAX3q9ZR AYzg== 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:message-id:subject:cc:to:from:date:dkim-signature; bh=OFwHGZmM8wqHN2mLtpKT/FoZS4DuP474ucBXNcxTZVA=; b=Te1q++96ahZSkhyPi9h7y1BzgX+rRIegU6+rLQBP8vQIjx9883aw0ySuQUerkmLc9l VweF4dIBxpnlZvJE3M5an4CxFUjAaapJc+pekVK8l8erv/sl0S0Nj20mDDntP/5k0C1v fgtqX5cyLNlFPl9GFKj9CwDMzhWHjJb52U+FMAB85Zyw1a/KMxcy/Dkysy7avf2OQmWy 4uegiW+g8ByyAQvER60ZH9LXdtIA6lchzLgDrggrDyXfNV7JiV43IMXnUm2Q6A29hp8y IrEknto4MjZBmEir3pClztu7ZoivGWlClPfDVabbGfIf9ptifBVPRR/3Qb88i7jUQO9E Dt5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GLeIyrcn; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y25si6238169ejb.546.2021.02.05.10.40.21; Fri, 05 Feb 2021 10:40:46 -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=@chromium.org header.s=google header.b=GLeIyrcn; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233568AbhBEQ5B (ORCPT + 99 others); Fri, 5 Feb 2021 11:57:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232977AbhBEQz3 (ORCPT ); Fri, 5 Feb 2021 11:55:29 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4859C061574 for ; Fri, 5 Feb 2021 10:37:11 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id e12so4020112pls.4 for ; Fri, 05 Feb 2021 10:37:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=OFwHGZmM8wqHN2mLtpKT/FoZS4DuP474ucBXNcxTZVA=; b=GLeIyrcnqQ4/LFNG6+Afvlafscx8C1O0gOHaXxsKan7L74NiEwk4WspSkwax8j2c0Z GNc/abUAOOIDjyt4g1biPXNH+3wBCCE+I+dRQ02xNGxfiTNDp0/YCmfC6eKmCyqaEDLQ 7wmxgWATXFhXmHIbm7ZMs0lTj8EbwgrL+rcAo= 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:references :mime-version:content-disposition:in-reply-to; bh=OFwHGZmM8wqHN2mLtpKT/FoZS4DuP474ucBXNcxTZVA=; b=J/oxm0KmXCdz4JKucHoX5EeF91M99OIDPfMTrQCpdUVpXl1GEGPZT4hH0mtuIL28F9 hMVF5dRkfFm+ipbVq90LKP6McMqbgsTRyaRd4B0aKu6cZAkBFoWswjI4nsoOOSGj6z4/ G76bA9AJsRLkgn0C68KJxdtXOt/PgK7xERwnpVBEGXgW3HubErCK94KKJ1ltT3BG63kx 4QVbm1/+sOQxldKk1D85JJQzv2LOggSuL1KTJNuxF5U6Fb+bhevGrQpZbexEcrM1Hujg IKmb+hSRU0dllxQTIFy92DTk7Ijy11kFlNI5JRBFj5l9Vrn1W4o5PEukv+Sr8wyomFvT n1og== X-Gm-Message-State: AOAM533Sib9/WnUbDwF/Fggk2BJThAtpe/gflfIu4l4/WiBOL0a9NmzG vLY/5fdZTLgLAERVRne5+Nji3Q== X-Received: by 2002:a17:902:82cb:b029:e1:2b0f:da57 with SMTP id u11-20020a17090282cbb02900e12b0fda57mr5302564plz.33.1612550231379; Fri, 05 Feb 2021 10:37:11 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id o1sm10799989pgq.1.2021.02.05.10.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 10:37:10 -0800 (PST) Date: Fri, 5 Feb 2021 10:37:09 -0800 From: Kees Cook To: Chris Wilson Cc: 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 , jannh@google.com Subject: Re: [PATCH] kernel: Expose SYS_kcmp by default Message-ID: <202102051030.1AF01772D@keescook> References: <20210205163752.11932-1-chris@chris-wilson.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210205163752.11932-1-chris@chris-wilson.co.uk> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 05, 2021 at 04:37:52PM +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. > > 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 > --- > init/Kconfig | 11 +++++++++++ > kernel/Makefile | 2 +- > tools/testing/selftests/seccomp/seccomp_bpf.c | 2 +- > 3 files changed, 13 insertions(+), 2 deletions(-) > > diff --git a/init/Kconfig b/init/Kconfig > index b77c60f8b963..f62fca13ac5b 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 > + default y I would expect this to be not default-y, especially if CHECKPOINT_RESTORE does a "select" on it. This is a really powerful syscall, but it is bounded by ptrace access controls, and uses pointer address obfuscation, so it may be okay to expose this. As it is, at least Ubuntu already has CONFIG_CHECKPOINT_RESTORE, so really, there's probably not much difference on exposure. So, if you drop the "default y", I'm fine with this. -Kees > + help > + Enable the file descriptor comparison system call. It provides > + user-space with the ability to compare two fd to see if they > + point to the same file, and check other attributes. > + > + If unsure, say Y. > + > 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