Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1127387ybp; Wed, 9 Oct 2019 09:10:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzi4/Xbeqdiq/KnyG+AbYgarNZwWIwQ0LAyHCSr0NHk721YNAHzu0dwUiduN77dx/OMFmRB X-Received: by 2002:a17:907:2132:: with SMTP id qo18mr3508868ejb.247.1570637407256; Wed, 09 Oct 2019 09:10:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570637407; cv=none; d=google.com; s=arc-20160816; b=TdAFLyCSRttVZ67x2qjfeXyRxepbu5fRAvjZlEfhhVwmx18AbMaS7aOTg5Auxb1Vku Y+zZGOCcI3/vmRngT5tJDXFfZ0JJvDjdJBXokF+/wqVnFfGJ6846MKSbZ8sbolqRWwgw p4aqI4dPf8Qv6UMH33OZ4q6ZZ/RpTpWoySGuc2wfmQbcSDq013krXvoMi6TmmWyLwCMa s/HQcwHkrO7d4m5e9H/7r+ijeWS5TdDKlthPmk63gdxk5vQMKHqyp1K1//7eBr2EhE/n J/9Bc8oCJUkWIJvMFUHgdgaLsKc3owcn1foLE4yEnV2/qkQ5N5VryX6X4fZ1xwQ+vNc4 nb/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=0cktpwp7oGjMQDIsInil09kNbODvJvAIWkIvYpazfRo=; b=0lm+7s0QesqB6ULodgbYwYgI8s5M4OwZVuaNV4uRxsVjFRbdNM05NyB+k+owgdjhr9 gdL9rNTELQXXAt3PNfamFv4ebC3XIazUY4C3Jff12hzv4l05T/wk1WLadqUJcEN61aYS CENuneT4S9ywMojeNBblFPgP6Vu+jLvCTegho14PaaIHGYI8wrJ4Vzm+CugaCtUoP3IZ 923wAc/WY0b4aXK9A6R0C+LrHD7zNQUh1a+6kvw7b0UwU5GrPKdkHGsR7wmPyrvEORQ8 MjifaBXtc+blmDtHdNWl7mAbdrItLzUOugVKQVk5FJ3/rNpKrww+Pdab5HQ4/TG/cGTS rpcQ== 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 j6si1361099ejj.37.2019.10.09.09.09.43; Wed, 09 Oct 2019 09:10:07 -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 S1731768AbfJIQJW (ORCPT + 99 others); Wed, 9 Oct 2019 12:09:22 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:41922 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731666AbfJIQJR (ORCPT ); Wed, 9 Oct 2019 12:09:17 -0400 Received: from [213.220.153.21] (helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iIEWW-00034Q-P7; Wed, 09 Oct 2019 16:09:12 +0000 From: Christian Brauner To: Alexei Starovoitov , Daniel Borkmann , bpf@vger.kernel.org Cc: Martin KaFai Lau , Song Liu , Yonghong Song , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Christian Brauner Subject: [PATCH 0/3] bpf: switch to new usercopy helpers Date: Wed, 9 Oct 2019 18:09:04 +0200 Message-Id: <20191009160907.10981-1-christian.brauner@ubuntu.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 /* Reference */ [1]: f5a1a536fa14 ("lib: introduce copy_struct_from_user() helper") 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 | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) -- 2.23.0