Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2295715pxb; Thu, 11 Feb 2021 08:54:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPP587QPzI6Q9ntleB+0kwDrygbaxRbmc5phZulMFTalurP+DgyvbcdO81gI+9s4ZWNT9u X-Received: by 2002:a17:906:3c1:: with SMTP id c1mr9015327eja.428.1613062458829; Thu, 11 Feb 2021 08:54:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613062458; cv=none; d=google.com; s=arc-20160816; b=deGw4x+kWI6ZXWnk/NVA+4wgV+7cjGWfERRTs/Z9/tCijDF70g9okAamqZLrDqejA2 083WOV1MFc+SUH9MRt0Iq4h6b3IgQgumbyvehGG4xOMHF9mO+8QfwbPZBpfBeQktF4Sr kxkQZovt9g/TqJBtiUmjSjdGPwcmbdsH3qAfUyuE6BxKhY0Dhl6gXCBTizw78BCNQ++G s/36O8riTmSb1FOD+Ib5Uuuq32DPEAHytr5uC8otdWxFDhAAbGX6myC86DEbVyfyITX+ BD1WK1ZCKlVl+zn7ozgz4pZWvbh/9aMGs55b9ZoBw24+7y2XYRs33JUbvLKBjeVNeyZe E3ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8ehJ35m6b6vY3byfuy0FTuxA8vtSVf9NMIvJAwknNzo=; b=Gq9DXPW63JrG2ExUjc6kxL7V1WoCx9mcZDp87WntObWNLdH90g9JgvBt2TTHkHFcE6 Z2lZUxBTTELdnlpHVZIZtzTyx2T3DheKn8EB6LkO6Ff0T1vCYSgb5QPnEib8sbp154hH Hw3TXV0f04xZ3bN7zLc7pK9KEssLWdNFmTXi81CDg/6ywB1h3TfbvYEOXn9CtPtNWEri TTkncJd58zxI/PcqWn58TAhx6dfVyz6alokQaWNy9A3vRSFHv3My3Dl6vvOOZn2WXPaB lIMU+GzSenWtvpszK1zE4Nm5v78X4zZ4zQCCb1sBMtDPAROJY9pAF7bh0qH0rTyglor0 24kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e4w2TzLp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bx4si4021807edb.268.2021.02.11.08.53.55; Thu, 11 Feb 2021 08:54:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=e4w2TzLp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229906AbhBKQvE (ORCPT + 99 others); Thu, 11 Feb 2021 11:51:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:57470 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229981AbhBKPjl (ORCPT ); Thu, 11 Feb 2021 10:39:41 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9364564F07; Thu, 11 Feb 2021 15:05:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613055926; bh=KGm6BrRijFSMwbWk/+YuKTspHhjNHf8+XnDYSjl74TE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e4w2TzLp5olvuzJA+2q3Ia/asO+n+ePdqd9mRJTUsgmOEz7dj+It5kR02BmBcUbmW XLx1JUGLi0qqE2mxMh+Kki9Sr8yIU5rboSB6OCaFLZxzxU+FBNPR7PFNhGEludtdrX 3wO4RVrDoaEEKVnN0D4VtBGpSdjJnImLd6JWFR7w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dave Wysochanski , Trond Myklebust , Sasha Levin Subject: [PATCH 5.10 39/54] SUNRPC: Move simple_get_bytes and simple_get_netobj into private header Date: Thu, 11 Feb 2021 16:02:23 +0100 Message-Id: <20210211150154.583738617@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210211150152.885701259@linuxfoundation.org> References: <20210211150152.885701259@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Wysochanski [ Upstream commit ba6dfce47c4d002d96cd02a304132fca76981172 ] 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 Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- 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 9548d075e06da..b998e4b736912 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h @@ -25,8 +25,7 @@ struct rpc_rqst; #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 4ecc2a9595674..5f42aa5fc6128 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 @@ gss_cred_set_ctx(struct rpc_cred *cred, struct gss_cl_ctx *ctx) 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 0000000000000..c5603242b54bf --- /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 ae9acf3a73898..1c092b05c2bba 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 @@ get_gss_krb5_enctype(int etype) 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) -- 2.27.0