Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp542671pxb; Thu, 21 Jan 2021 13:24:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJz8b9IbyzcLZ1CC9a9KCxHt6sJAMpCA27KfKWRvCgW1ZEwAxquOZMQILjBNbFokphXieUms X-Received: by 2002:a05:6402:22e9:: with SMTP id dn9mr860689edb.61.1611264289396; Thu, 21 Jan 2021 13:24:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611264289; cv=none; d=google.com; s=arc-20160816; b=wNQhPU5PW6UIeS7n6UbPhxk6n8CNlmtIUbMHxOxwQNsqenAY4Yl/YJzmWjG21WXaoq xzJ4MQcCVjB3XDYbqF3eFPtKrgcWeJphNq5rwjEicjNsn4S56v1PteobaGIH+Jrr6+Eg j1CcgMhGDVoVsn7yaVB7nVW2JKvlTlxW+g+Q3eHSz32RCIETuYRhYuj9KMg6MVLCFJcb nPlm071gezikuSRyKmIwhQS6ryW283ojccrKouh3LRwHtgny1UbTny2hd2uWFNYjpsFr 7KuTtXxA6bP+sSkyeleC5Leg1EXfjgdjvyeO3jQfKFmlytUUfUXggPCxoEEH3rPiRvye Iu5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=R5JiLQ1gkm6KRQvQTiDbUFNTAL57tDtVahInQIeEyeE=; b=b2VyWtIGZSBGMiyRyjocjx0LDjXD1IABYmTQZ2LqbhADdjPTLDBmFqjVV94MweOFa4 jXMN3hL2648ws1Xa2+Fvs+Zflp0zN9T+vhamDESvHfz8ivMLdPqdkW1oWtoH/77yJYRc vshwhsvuYdrR9yOJJHjfUC3ATQw4P1KrYnNe1cpKRgJdxZi4FILyLGgmIxYM+TexAqOM Sqx+nvsDK8Y892DrnsAqq/U7rQwkRGuS31V5ptH4DXDDsEEWwKjc9rAlKoONiFGEyhLq XSVvSQS0fVA5OoumulhRooRcCxCARCwNE2YAs0jIS+KXKuETnYbH82R1DmUQiaCx/OF3 eXuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aTNgOPbF; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q15si2630091edi.284.2021.01.21.13.24.24; Thu, 21 Jan 2021 13:24:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-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=@redhat.com header.s=mimecast20190719 header.b=aTNgOPbF; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726296AbhAUVXa (ORCPT + 99 others); Thu, 21 Jan 2021 16:23:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:37354 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726000AbhAUVX1 (ORCPT ); Thu, 21 Jan 2021 16:23:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611264120; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=R5JiLQ1gkm6KRQvQTiDbUFNTAL57tDtVahInQIeEyeE=; b=aTNgOPbF76FPoQB79BSjofeByhLuBoj0gFWZSKTl0cOrg4tuxGKR3WETWopFTEa9vVqBPL 9MGfN1eM2iWRsx9sOY2lMKjpK0i6TKV6TO97e7RK0MPVV3KtIdnn1mjnyS9YfCtL+U37CM AcJ1wWe2xeETxFvRwsLmWi06SsDo4hY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-414-NYRUo3wPOKWlarmLmAW2mw-1; Thu, 21 Jan 2021 16:17:39 -0500 X-MC-Unique: NYRUo3wPOKWlarmLmAW2mw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0E63C107ACE8; Thu, 21 Jan 2021 21:17:38 +0000 (UTC) Received: from dwysocha.rdu.csb (ovpn-113-28.rdu2.redhat.com [10.10.113.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 783165D749; Thu, 21 Jan 2021 21:17:37 +0000 (UTC) From: Dave Wysochanski To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH v3 1/2] SUNRPC: Move simple_get_bytes and simple_get_netobj into private header Date: Thu, 21 Jan 2021 16:17:23 -0500 Message-Id: <1611263844-32608-2-git-send-email-dwysocha@redhat.com> In-Reply-To: <1611263844-32608-1-git-send-email-dwysocha@redhat.com> References: <1611263844-32608-1-git-send-email-dwysocha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Remove duplicated helper functions to parse opaque XDR objects and place inside new file net/sunrpc/auth_gss/auth_gss_internal.h. In the new file carry the license and copyright from the source file net/sunrpc/auth_gss/auth_gss.c. Finally, update the comment inside include/linux/sunrpc/xdr.h since lockd is not the only user of struct xdr_netobj. Signed-off-by: Dave Wysochanski --- include/linux/sunrpc/xdr.h | 3 +-- net/sunrpc/auth_gss/auth_gss.c | 30 +---------------------- net/sunrpc/auth_gss/auth_gss_internal.h | 42 +++++++++++++++++++++++++++++++++ net/sunrpc/auth_gss/gss_krb5_mech.c | 31 ++---------------------- 4 files changed, 46 insertions(+), 60 deletions(-) create mode 100644 net/sunrpc/auth_gss/auth_gss_internal.h diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index 19b6dea27367..b26213ae8c1a 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h @@ -25,8 +25,7 @@ #define XDR_QUADLEN(l) (((l) + 3) >> 2) /* - * Generic opaque `network object.' At the kernel level, this type - * is used only by lockd. + * Generic opaque `network object.' */ #define XDR_MAX_NETOBJ 1024 struct xdr_netobj { diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index 4ecc2a959567..5f42aa5fc612 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c @@ -29,6 +29,7 @@ #include #include +#include "auth_gss_internal.h" #include "../netns.h" #include @@ -125,35 +126,6 @@ struct gss_auth { clear_bit(RPCAUTH_CRED_NEW, &cred->cr_flags); } -static const void * -simple_get_bytes(const void *p, const void *end, void *res, size_t len) -{ - const void *q = (const void *)((const char *)p + len); - if (unlikely(q > end || q < p)) - return ERR_PTR(-EFAULT); - memcpy(res, p, len); - return q; -} - -static inline const void * -simple_get_netobj(const void *p, const void *end, struct xdr_netobj *dest) -{ - const void *q; - unsigned int len; - - p = simple_get_bytes(p, end, &len, sizeof(len)); - if (IS_ERR(p)) - return p; - q = (const void *)((const char *)p + len); - if (unlikely(q > end || q < p)) - return ERR_PTR(-EFAULT); - dest->data = kmemdup(p, len, GFP_NOFS); - if (unlikely(dest->data == NULL)) - return ERR_PTR(-ENOMEM); - dest->len = len; - return q; -} - static struct gss_cl_ctx * gss_cred_get_ctx(struct rpc_cred *cred) { diff --git a/net/sunrpc/auth_gss/auth_gss_internal.h b/net/sunrpc/auth_gss/auth_gss_internal.h new file mode 100644 index 000000000000..c5603242b54b --- /dev/null +++ b/net/sunrpc/auth_gss/auth_gss_internal.h @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: BSD-3-Clause +/* + * linux/net/sunrpc/auth_gss/auth_gss_internal.h + * + * Internal definitions for RPCSEC_GSS client authentication + * + * Copyright (c) 2000 The Regents of the University of Michigan. + * All rights reserved. + * + */ +#include +#include +#include + +static inline const void * +simple_get_bytes(const void *p, const void *end, void *res, size_t len) +{ + const void *q = (const void *)((const char *)p + len); + if (unlikely(q > end || q < p)) + return ERR_PTR(-EFAULT); + memcpy(res, p, len); + return q; +} + +static inline const void * +simple_get_netobj(const void *p, const void *end, struct xdr_netobj *dest) +{ + const void *q; + unsigned int len; + + p = simple_get_bytes(p, end, &len, sizeof(len)); + if (IS_ERR(p)) + return p; + q = (const void *)((const char *)p + len); + if (unlikely(q > end || q < p)) + return ERR_PTR(-EFAULT); + dest->data = kmemdup(p, len, GFP_NOFS); + if (unlikely(dest->data == NULL)) + return ERR_PTR(-ENOMEM); + dest->len = len; + return q; +} diff --git a/net/sunrpc/auth_gss/gss_krb5_mech.c b/net/sunrpc/auth_gss/gss_krb5_mech.c index ae9acf3a7389..1c092b05c2bb 100644 --- a/net/sunrpc/auth_gss/gss_krb5_mech.c +++ b/net/sunrpc/auth_gss/gss_krb5_mech.c @@ -21,6 +21,8 @@ #include #include +#include "auth_gss_internal.h" + #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) # define RPCDBG_FACILITY RPCDBG_AUTH #endif @@ -143,35 +145,6 @@ return NULL; } -static const void * -simple_get_bytes(const void *p, const void *end, void *res, int len) -{ - const void *q = (const void *)((const char *)p + len); - if (unlikely(q > end || q < p)) - return ERR_PTR(-EFAULT); - memcpy(res, p, len); - return q; -} - -static const void * -simple_get_netobj(const void *p, const void *end, struct xdr_netobj *res) -{ - const void *q; - unsigned int len; - - p = simple_get_bytes(p, end, &len, sizeof(len)); - if (IS_ERR(p)) - return p; - q = (const void *)((const char *)p + len); - if (unlikely(q > end || q < p)) - return ERR_PTR(-EFAULT); - res->data = kmemdup(p, len, GFP_NOFS); - if (unlikely(res->data == NULL)) - return ERR_PTR(-ENOMEM); - res->len = len; - return q; -} - static inline const void * get_key(const void *p, const void *end, struct krb5_ctx *ctx, struct crypto_sync_skcipher **res) -- 1.8.3.1