Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp6916287ybp; Wed, 16 Oct 2019 00:35:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyu9LJtjvSkN3+3HUDGW3xB9rSTK6s8rakVUUg0eBuVr/7TlqjZL2njXm0GdDRHeEC3LAQE X-Received: by 2002:a17:906:4757:: with SMTP id j23mr36380200ejs.174.1571211312666; Wed, 16 Oct 2019 00:35:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571211312; cv=none; d=google.com; s=arc-20160816; b=mjMeKjuKBEAamI+7dkyY1T4lVDjh2XWghk19T9GWZslg3OxBucNe8ZIfe5TPNLl+qq UjLOPdQ5+3Qyw3q7DUKlj5GKHhmSIN9nvqB1I5BOd4WizIs3cPVrWWLzzrxWfA86+FIn p9CHdwnS3sU82pv9jWqe1DO6pVjVVWFXpGBQQ16OXy3z9Yw1qQvKvPtxlxAFMhnQ5A53 /zgqelDkiISPHIfIXyGocRdiUj/zy4Gh7MkvqaYuhUF03VCby1zGDe6Astw47BfdHBPd t128ED1vsB5XTX1zXH4ZRESgMqxn92GdSpQV7jOUPdCwwAXOFLXNiGhcy5xAV5ik9mB6 uusg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=sX8jTMX1nSIXGcCRNZ453mld0cSsi8SG9vJtVFWmkgY=; b=w378ScfGdZWP7TXem0SYooMyJFb/D457kis01WUk7QhTWKgXp3X3L/hoF6Q6iGQWGz F0+9oGE9sQq7qMAC7bB/TihDSV0cylOkVaG62wUs38xMAExMHxCTSrB4mF8oWRG/Cvx0 FzqBPoIlMFOFihT6scTat5bEm+Mgwx9XBAj8rrktBAU0B0wpaybizkJ1/Gkq2Atp1th0 vRlIdT98/N0T4qBGyye3G1D9pO8uN25+cRc5WpvCd9nxpdHH2QEwtRLPrrvwrzkHfIG+ 4/8iOLr8gDQIX1S7o89BDEyNXcVIC9T/588A6bT3BOSSh1t04nWdRXB/8iNHWrssFMsM LBmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="ES/OzHKn"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nj7si14998981ejb.262.2019.10.16.00.34.49; Wed, 16 Oct 2019 00:35:12 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="ES/OzHKn"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390056AbfJOWqK (ORCPT + 99 others); Tue, 15 Oct 2019 18:46:10 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:37920 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390034AbfJOWqI (ORCPT ); Tue, 15 Oct 2019 18:46:08 -0400 Received: by mail-lj1-f193.google.com with SMTP id b20so21950974ljj.5; Tue, 15 Oct 2019 15:46:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sX8jTMX1nSIXGcCRNZ453mld0cSsi8SG9vJtVFWmkgY=; b=ES/OzHKnNaTbjDoZaXmFsqYm4h8O0iW4SYK/1ndLuLvY7RUpbwD2ej7ZWtshgaPazd UUnQwewSFBIjRDF44nesd7JXsVX/k50opp+s5i5b2f19wxk/LbSzVk13LFGb+CmUXKlV 092qU3KAwKp92DLApsSN7InO1e5M6HAIoyijAJkq862bxOQ/FEc3MztS6PHQuENM75Yx GjUKKm+9FNF4fghj+tPnOBSUSvEPMCmdTXXQaSyrDys0wQ9C/qOqkBoiS3sP28uQwYG3 KQKnDniiiVXYLDbejzoUpnDGXbTxZ8ulLBvxQz2fRcdjco3lJrfiSWsU+sgsT+1QQk8j ZsVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sX8jTMX1nSIXGcCRNZ453mld0cSsi8SG9vJtVFWmkgY=; b=tUBfF9bMuSvxERqghdiiE3zDWsnvAP5Oo8ucMz1GvO8c8f/dmYOMhRTvkfAF+LCPmp +aduvoAbEpD/BNijO3MwKodzF7ZlwnMlGbWE2czPNIzz+0wKT0bgM3+T+8sWYIXXzqOa k5g1mvrMeZ+5e2EKHAxwQQdYHs8q4sDFwogs2qPmGpLeW20H6yChSdICDspAvXE9SeGd 2NzQJHxwLqB2lHfDoJGL7JFfyH00yMTYjeSAeG0xwgHv8h9LV1KsYhk3qksq9h61P4Hf mpqU51b+tIeX6RF6+T2+tyIWt5gRG4HgRe8cnu/On+vC+xLKakKPiNnPp8z0n/6E4H1n BaSg== X-Gm-Message-State: APjAAAU8iIR7/IUL7uaSbzDbD5ysGyC2SpI26r8/HFnCB6WBqkfE2+pK pGHloyGcnIoG103gpPvpYKT92afj/YtCs/P1gpg= X-Received: by 2002:a2e:6c15:: with SMTP id h21mr23559078ljc.10.1571179565793; Tue, 15 Oct 2019 15:46:05 -0700 (PDT) MIME-Version: 1.0 References: <20191009160907.10981-1-christian.brauner@ubuntu.com> <20191010092647.cpxh7neqgabq36gt@wittgenstein> In-Reply-To: <20191010092647.cpxh7neqgabq36gt@wittgenstein> From: Alexei Starovoitov Date: Tue, 15 Oct 2019 15:45:54 -0700 Message-ID: Subject: Re: [PATCH 0/3] bpf: switch to new usercopy helpers To: Christian Brauner Cc: Alexei Starovoitov , Daniel Borkmann , bpf , Martin KaFai Lau , Song Liu , Yonghong Song , Network Development , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 10, 2019 at 2:26 AM Christian Brauner wrote: > > On Wed, Oct 09, 2019 at 04:06:18PM -0700, Alexei Starovoitov wrote: > > On Wed, Oct 9, 2019 at 9:09 AM 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. > > > > check_zeroed_user() is not in bpf-next. > > we will let this set sit in patchworks for some time until bpf-next > > is merged back into net-next and we fast forward it. > > Then we can apply it (assuming no conflicts). > > Sounds good to me. Just ping me when you need me to resend rebase onto > bpf-next. -rc1 is now in bpf-next. I took a look at patches and they look good overall. In patches 2 and 3 the zero init via "= {};" should be unnecessary anymore due to copy_struct_from_user() logic, right? Could you also convert all other case in kernel/bpf/, so bpf_check_uarg_tail_zero() can be removed ? Otherwise the half-way conversion will look odd.