SUNRPC: Move simple_get_bytes and simple_get_netobj into private header
[ Upstream commit ba6dfce47c
]
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 <dwysocha@redhat.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
6fb6d5410e
commit
eda725f8cf
@ -25,8 +25,7 @@ struct rpc_rqst;
|
|||||||
#define XDR_QUADLEN(l) (((l) + 3) >> 2)
|
#define XDR_QUADLEN(l) (((l) + 3) >> 2)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic opaque `network object.' At the kernel level, this type
|
* Generic opaque `network object.'
|
||||||
* is used only by lockd.
|
|
||||||
*/
|
*/
|
||||||
#define XDR_MAX_NETOBJ 1024
|
#define XDR_MAX_NETOBJ 1024
|
||||||
struct xdr_netobj {
|
struct xdr_netobj {
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
#include <linux/hashtable.h>
|
#include <linux/hashtable.h>
|
||||||
|
|
||||||
|
#include "auth_gss_internal.h"
|
||||||
#include "../netns.h"
|
#include "../netns.h"
|
||||||
|
|
||||||
#include <trace/events/rpcgss.h>
|
#include <trace/events/rpcgss.h>
|
||||||
@ -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);
|
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 *
|
static struct gss_cl_ctx *
|
||||||
gss_cred_get_ctx(struct rpc_cred *cred)
|
gss_cred_get_ctx(struct rpc_cred *cred)
|
||||||
{
|
{
|
||||||
|
42
net/sunrpc/auth_gss/auth_gss_internal.h
Normal file
42
net/sunrpc/auth_gss/auth_gss_internal.h
Normal file
@ -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 <linux/err.h>
|
||||||
|
#include <linux/string.h>
|
||||||
|
#include <linux/sunrpc/xdr.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
@ -21,6 +21,8 @@
|
|||||||
#include <linux/sunrpc/xdr.h>
|
#include <linux/sunrpc/xdr.h>
|
||||||
#include <linux/sunrpc/gss_krb5_enctypes.h>
|
#include <linux/sunrpc/gss_krb5_enctypes.h>
|
||||||
|
|
||||||
|
#include "auth_gss_internal.h"
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
|
#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
|
||||||
# define RPCDBG_FACILITY RPCDBG_AUTH
|
# define RPCDBG_FACILITY RPCDBG_AUTH
|
||||||
#endif
|
#endif
|
||||||
@ -143,35 +145,6 @@ get_gss_krb5_enctype(int etype)
|
|||||||
return NULL;
|
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 *
|
static inline const void *
|
||||||
get_key(const void *p, const void *end,
|
get_key(const void *p, const void *end,
|
||||||
struct krb5_ctx *ctx, struct crypto_sync_skcipher **res)
|
struct krb5_ctx *ctx, struct crypto_sync_skcipher **res)
|
||||||
|
Reference in New Issue
Block a user