From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.6 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15443C433E3 for ; Thu, 23 Jul 2020 16:40:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E04502067D for ; Thu, 23 Jul 2020 16:40:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="gwjAdDF9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729910AbgGWQkk (ORCPT ); Thu, 23 Jul 2020 12:40:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728093AbgGWQkj (ORCPT ); Thu, 23 Jul 2020 12:40:39 -0400 Received: from mail-yb1-xb44.google.com (mail-yb1-xb44.google.com [IPv6:2607:f8b0:4864:20::b44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C6C7C0619E2 for ; Thu, 23 Jul 2020 09:40:39 -0700 (PDT) Received: by mail-yb1-xb44.google.com with SMTP id g6so3143894ybo.11 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=tIDbVHGhOhTkhfEauiR46lXtEjcwgrlUHzIeb7b25Pq4bcaSr+rRSf+AifSuKhUdbK fbSu35+CRno/OAJqhbb9NxDWlSWHEzbo8fJ7yi/XnSROxWOJGS7pSu+44TYcyGpIxaVI OiLC3cG0nugs0L6bCjhigXt6aDaZtozYOk8oKxAZWwYJVsS2/uvunTtR9+4ddVaU039R Qj/1WaW0EEvwKFzk5n6num8gDPFoX1pruIvLvWpC6oR3ynTxvXBepkgpsmAauUejjuOz N3IEbfquABtyf1t0lq1ivUe6kURlBtwWbW889DfnXUYpL62Bg651HZZ49nmDbd0I7nFe Eu3Q== X-Gm-Message-State: AOAM530ld8JdO9AOSYEcw2Wko2+ioVsVYIFtTJbu3u3B+F5/A6x4TjSg fuZCg3IaDU8Fr/4+pFSlcdmrXBLlrhzcyDvAeQqTHw== X-Google-Smtp-Source: ABdhPJwjoH5EQjleheyC3y94ZN3qZdobs4/50/anePotqNf3BbB0YqTnucY8g4u2RzRMw5fRhYkM1LWDXZ+gqUBrIW0= 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-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@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.