Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1472635ybh; Thu, 23 Jul 2020 09:41:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypQNT4117OuwAf83vbJdUtXTiX63QCyPihdIFcjltlON0sxnMnCLhGN9eBJIqUUx5o3D54 X-Received: by 2002:aa7:c496:: with SMTP id m22mr5038616edq.336.1595522469189; Thu, 23 Jul 2020 09:41:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595522469; cv=none; d=google.com; s=arc-20160816; b=sNeR4Y01uenVgZl2O7b56pyGnb9Uf0/znNvNX9eFGp/Mb92FpSLkUYdCv3XeEwdQAH z0mNpmUBx7T6A5NAKVrmnEYcV294kXRYvBLg93hQWaMaFk6lW9LMPXWcMJudJFBwN+7o Ds4ksPaOmOCznT/zt95+NAbhsUM3jwCzRrr62hm/eqSWOMkCx7bHgRsyqJQs1kj1v/NV mE7I9tb1zf2HuJDPDnwvAJ/cRgZwGPS/v7fxSQU/jCTGtmVw325fFnOFrwc+ryrZfzmY NEQyoB4WAD5259dfyZBGReqJuxlwZW+cFfr6l5zncGa2Cp+H0jHAwh7SxWtU0ra90igH E4GA== 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=gMZVcJy5uwQT4vGlr1ERHcQqosY3c4kI9divmT2Lqpo=; b=GcdYalENanG4nsr7sfrwzjJFg7hGrhC1qyjmDkijAoWbtH02/Xyb1kUJ1yG/RFdBf7 UP/ffUQIogQ7OSVh51+YUG0+w2RrbE1FVSrvLCbAq2axdA4FBniJSwYWJhKzH6YwZ0ZG 1XZ1YZ+Fqj6/iurRVQeesHMS1YFBmV9/Cu8ECssKFvMI81PoGMVQ5oXFoI/zhJ+ufwTg bhvOWqm4YzmLRS5dbYpjXIs/50NZZv1UrAuyfV41c4FyS79dShKwZAgGaO9Yr5f4OTYM gm01wyMyb7jYI6GYkMX0s/uoL34bQAkPW/ypkyLD9dEMl4N112KMljohQOaicqJsHRD5 pTQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=gwjAdDF9; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g22si2306363edq.111.2020.07.23.09.40.45; Thu, 23 Jul 2020 09:41:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-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=@google.com header.s=20161025 header.b=gwjAdDF9; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726632AbgGWQkk (ORCPT + 99 others); Thu, 23 Jul 2020 12:40:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729849AbgGWQkj (ORCPT ); Thu, 23 Jul 2020 12:40:39 -0400 Received: from mail-yb1-xb41.google.com (mail-yb1-xb41.google.com [IPv6:2607:f8b0:4864:20::b41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 986E9C0619E3 for ; Thu, 23 Jul 2020 09:40:39 -0700 (PDT) Received: by mail-yb1-xb41.google.com with SMTP id n141so965851ybf.3 for ; Thu, 23 Jul 2020 09:40:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gMZVcJy5uwQT4vGlr1ERHcQqosY3c4kI9divmT2Lqpo=; b=gwjAdDF942fvpXcwvyR0uuIMKC72vX+1xaZmY+P/HlmQuhIFDMmqtrrmpEAYoODFls 2whE4wMib2QcLaOVE4J+SdVBQ6P2JsY+v8YTFDd3JbEzache4FI5T4xBht2IkLXzQ/Sy 1WIGux4f/lVv0pdf+puWJ2nV8J8wAU2lYqlJCRbXSl2WNeWZR9h1y1lVklRZc/KIqgKe Aj/ehWw+f2o0CsdkKfDY/zbJ5hlw20DhQPkwOJEN7mcdPxjJE6/p+eukZAHUXZngVbCf sdt5+ZH+ulKqsBPsP5u7/dtuM4Y4W/S7rVtNSNPkcxfWu5kl7dPPev0Qj6brKbcngU4o aoNg== 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=gMZVcJy5uwQT4vGlr1ERHcQqosY3c4kI9divmT2Lqpo=; b=TF254k0d8J/TugHed7rzWvVPrQ62+5hu6W7tV+qmYemuAwJaiwxVaD2BOOPR4zNnKW quBlcLqaBe1o5zUX5c2LQGqNofJ0bbKiqOGx8Rll9F93bplY+4F//x39VnxBEJpAaMXv 9o9P5K21E8RvBGFRap84L6UUPt398QiKGlsO7Eoea/a4ziHawRb6ZibMLQDEJvADM2Vy Xm4STuxXb/yH4jyh0rknXKuz4hiYsuWgiGg9dXJuxYxL7y5WF0Z5l8CoprR3ZAGidN2C nv8c9Iei5U3MLPODvv/HWYIbJkB+IrXTk+aba/ER70DpWvG5J9VBaTJkM299VuPAOZMe XMsg== X-Gm-Message-State: AOAM533YEABJT0uii6pxibXCH+bcroGq0UKJuWH2JotNFNiQWBPMF95N DukLo6WPuVva+UFms1p7Si41+oEvulzQ08H81b6/jA== X-Received: by 2002:a25:a121:: with SMTP id z30mr8500302ybh.408.1595522438544; Thu, 23 Jul 2020 09:40:38 -0700 (PDT) MIME-Version: 1.0 References: <20200723060908.50081-1-hch@lst.de> <20200723060908.50081-5-hch@lst.de> In-Reply-To: <20200723060908.50081-5-hch@lst.de> From: Eric Dumazet Date: Thu, 23 Jul 2020 09:40:27 -0700 Message-ID: Subject: Re: [PATCH 04/26] net: add a new sockptr_t type To: Christoph Hellwig Cc: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Alexey Kuznetsov , Hideaki YOSHIFUJI , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , LKML , netdev , bpf , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-sctp@vger.kernel.org, linux-hams@vger.kernel.org, linux-bluetooth@vger.kernel.org, bridge@lists.linux-foundation.org, linux-can@vger.kernel.org, dccp@vger.kernel.org, linux-decnet-user@lists.sourceforge.net, linux-wpan@vger.kernel.org, linux-s390@vger.kernel.org, mptcp@lists.01.org, lvs-devel@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org On Wed, Jul 22, 2020 at 11:09 PM Christoph Hellwig wrote: > > Add a uptr_t type that can hold a pointer to either a user or kernel > memory region, and simply helpers to copy to and from it. > > Signed-off-by: Christoph Hellwig > --- > include/linux/sockptr.h | 104 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 104 insertions(+) > create mode 100644 include/linux/sockptr.h > > diff --git a/include/linux/sockptr.h b/include/linux/sockptr.h > new file mode 100644 > index 00000000000000..700856e13ea0c4 > --- /dev/null > +++ b/include/linux/sockptr.h > @@ -0,0 +1,104 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * Copyright (c) 2020 Christoph Hellwig. > + * > + * Support for "universal" pointers that can point to either kernel or userspace > + * memory. > + */ > +#ifndef _LINUX_SOCKPTR_H > +#define _LINUX_SOCKPTR_H > + > +#include > +#include > + > +typedef struct { > + union { > + void *kernel; > + void __user *user; > + }; > + bool is_kernel : 1; > +} sockptr_t; > I am not sure why you chose sockptr_t for something that really seems generic. Or is it really meant to be exclusive to setsockopt() and/or getsockopt() ? If the first user of this had been futex code, we would have used futexptr_t, I guess.