Received: by 2002:a17:90a:37e8:0:0:0:0 with SMTP id v95csp7145499pjb; Wed, 16 Oct 2019 00:49:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8tCVGsPgFd5fjydqeEzHiBS2/X/AhoOy6AnDI+ShZcZ2rZ0iUbj0rZRR0A+a8OAtXXiBD X-Received: by 2002:a05:6402:1b1a:: with SMTP id by26mr37928724edb.178.1571212148381; Wed, 16 Oct 2019 00:49:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571212148; cv=none; d=google.com; s=arc-20160816; b=FXW7mN76DvxadOwlg7aiI+GpwV96JdZsbUpkfRvOHsYz3SjbtDd2KNiTyfxYftrXPm 255kxnvuYx98g8aLTpaz4l/CezIAWtFhnIfcsNEUpSliD6Jngu7Hmcb11dK9nIQyyowO Q5p8+M3Cp/KVj+N3Edcrkjrfrzyum5JG2qHpQMA2JnLah+QYeutxJ5fjyIMXnedVyD7Q MNXQb7MAkaRPqG2WT6KnBF/uvoivd1+BSxTufSOgembrUS/o/5xU/Z9RKiZm6cA6DzD0 flAhnvPqLmsccHnQdEb42tuWfV9YtWDGCF0O8u9Z8k/PmIQGHmNgUHLU+SIM3p7yEHdR z9Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=suuGItvrKkFtPovpv3Jtx8/Px+m3jWo6g6CLuNp+rfw=; b=Grm8wPe7OSPLXN4QgMLtwBbjwz1y3tu/6Scb8ECAEqaL9IeEjFyIKMT/I3FVj8k6I1 M4wQYVnTFL43WamDyCNP8MozLa1l+zInMoYakmDM7Pnq82N2i6uLjdCDo5jgo+cnS9Iy VFE7e7hqkOLF3P2M6b4GlH7pB4hphwAcSsg6TrjUJidZttBsgiavj2d42XANBH2kU+fH 53j9bkQAHcT02GSpWBYABCqKyFS+zyy5SJvw0+HYJltt5Zeu8Qs6ck/lhYqWkIpYf1f/ HDUCDnAzUUlhCWQHwpz2+R0RaT+qX1/BDOBJ6PPJfR2Zrvf00N6lNNpSpZEwkrJh5mSg JB1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j14si13961049edt.298.2019.10.16.00.48.44; Wed, 16 Oct 2019 00:49:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731178AbfJPAsN (ORCPT + 99 others); Tue, 15 Oct 2019 20:48:13 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:53490 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726362AbfJPAsN (ORCPT ); Tue, 15 Oct 2019 20:48:13 -0400 Received: from [213.220.153.21] (helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iKXU2-0006Y2-T7; Wed, 16 Oct 2019 00:48:10 +0000 Date: Wed, 16 Oct 2019 02:48:10 +0200 From: Christian Brauner To: ast@kernel.org Cc: bpf@vger.kernel.org, daniel@iogearbox.net, kafai@fb.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, songliubraving@fb.com, yhs@fb.com Subject: Re: [PATCH v2 0/3] bpf: switch to new usercopy helpers Message-ID: <20191016004809.tgw6zznr6ukppplp@wittgenstein> References: <20191009160907.10981-1-christian.brauner@ubuntu.com> <20191016004138.24845-1-christian.brauner@ubuntu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191016004138.24845-1-christian.brauner@ubuntu.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 16, 2019 at 02:41:35AM +0200, Christian Brauner wrote: > Hey everyone, > > In v5.4-rc2 we added two new helpers check_zeroed_user() and > copy_struct_from_user() including selftests (cf. [1]). It is a generic > interface designed to copy a struct from userspace. The helpers will be > especially useful for structs versioned by size of which we have quite a > few. > > The most obvious benefit is that this helper lets us get rid of > duplicate code. We've already switched over sched_setattr(), perf_event_open(), > and clone3(). More importantly it will also help to ensure that users > implementing versioning-by-size end up with the same core semantics. > > This point is especially crucial since we have at least one case where > versioning-by-size is used but with slighly different semantics: > sched_setattr(), perf_event_open(), and clone3() all do do similar > checks to copy_struct_from_user() while rt_sigprocmask(2) always rejects > differently-sized struct arguments. > > This little series switches over bpf codepaths that have hand-rolled > implementations of these helpers. > > Thanks! > Christian > > /* v1 */ > Link: https://lore.kernel.org/r/20191009160907.10981-1-christian.brauner@ubuntu.com > > /* v2 */ > - rebase onto bpf-next > > /* Reference */ > [1]: f5a1a536fa14 ("lib: introduce copy_struct_from_user() helper") Alexei, instead of applying the series you can also just pull from me: The following changes since commit 5bc60de50dfea235634fdf38cbc992fb968d113b: selftests: bpf: Don't try to read files without read permission (2019-10-15 16:27:25 -0700) are available in the Git repository at: git@gitolite.kernel.org:pub/scm/linux/kernel/git/brauner/linux tags/bpf-copy-struct-from-user for you to fetch changes up to da1699b959d182bb161be3ffc17eab063b2aedd2: bpf: use copy_struct_from_user() in bpf() syscall (2019-10-16 02:35:11 +0200) ---------------------------------------------------------------- bpf-copy-struct-from-user ---------------------------------------------------------------- Christian Brauner (3): bpf: use check_zeroed_user() in bpf_check_uarg_tail_zero() bpf: use copy_struct_from_user() in bpf_prog_get_info_by_fd() bpf: use copy_struct_from_user() in bpf() syscall kernel/bpf/syscall.c | 46 ++++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 28 deletions(-)