Commit 2dbd3cac authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-3.10' of git://linux-nfs.org/~bfields/linux

Pull nfsd fixes from Bruce Fields:
 "Small fixes for two bugs and two warnings"

* 'for-3.10' of git://linux-nfs.org/~bfields/linux:
  nfsd: fix oops when legacy_recdir_name_error is passed a -ENOENT error
  SUNRPC: fix decoding of optional gss-proxy xdr fields
  SUNRPC: Refactor gssx_dec_option_array() to kill uninitialized warning
  nfsd4: don't allow owner override on 4.1 CLAIM_FH opens
parents a77c0058 7255e716
...@@ -279,6 +279,7 @@ do_open_fhandle(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, str ...@@ -279,6 +279,7 @@ do_open_fhandle(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, str
{ {
struct svc_fh *current_fh = &cstate->current_fh; struct svc_fh *current_fh = &cstate->current_fh;
__be32 status; __be32 status;
int accmode = 0;
/* We don't know the target directory, and therefore can not /* We don't know the target directory, and therefore can not
* set the change info * set the change info
...@@ -290,9 +291,19 @@ do_open_fhandle(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, str ...@@ -290,9 +291,19 @@ do_open_fhandle(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, str
open->op_truncate = (open->op_iattr.ia_valid & ATTR_SIZE) && open->op_truncate = (open->op_iattr.ia_valid & ATTR_SIZE) &&
(open->op_iattr.ia_size == 0); (open->op_iattr.ia_size == 0);
/*
* In the delegation case, the client is telling us about an
* open that it *already* performed locally, some time ago. We
* should let it succeed now if possible.
*
* In the case of a CLAIM_FH open, on the other hand, the client
* may be counting on us to enforce permissions (the Linux 4.1
* client uses this for normal opens, for example).
*/
if (open->op_claim_type == NFS4_OPEN_CLAIM_DELEG_CUR_FH)
accmode = NFSD_MAY_OWNER_OVERRIDE;
status = do_open_permission(rqstp, current_fh, open, status = do_open_permission(rqstp, current_fh, open, accmode);
NFSD_MAY_OWNER_OVERRIDE);
return status; return status;
} }
......
...@@ -146,7 +146,7 @@ nfs4_make_rec_clidname(char *dname, const struct xdr_netobj *clname) ...@@ -146,7 +146,7 @@ nfs4_make_rec_clidname(char *dname, const struct xdr_netobj *clname)
* then disable recovery tracking. * then disable recovery tracking.
*/ */
static void static void
legacy_recdir_name_error(int error) legacy_recdir_name_error(struct nfs4_client *clp, int error)
{ {
printk(KERN_ERR "NFSD: unable to generate recoverydir " printk(KERN_ERR "NFSD: unable to generate recoverydir "
"name (%d).\n", error); "name (%d).\n", error);
...@@ -159,9 +159,7 @@ legacy_recdir_name_error(int error) ...@@ -159,9 +159,7 @@ legacy_recdir_name_error(int error)
if (error == -ENOENT) { if (error == -ENOENT) {
printk(KERN_ERR "NFSD: disabling legacy clientid tracking. " printk(KERN_ERR "NFSD: disabling legacy clientid tracking. "
"Reboot recovery will not function correctly!\n"); "Reboot recovery will not function correctly!\n");
nfsd4_client_tracking_exit(clp->net);
/* the argument is ignored by the legacy exit function */
nfsd4_client_tracking_exit(NULL);
} }
} }
...@@ -184,7 +182,7 @@ nfsd4_create_clid_dir(struct nfs4_client *clp) ...@@ -184,7 +182,7 @@ nfsd4_create_clid_dir(struct nfs4_client *clp)
status = nfs4_make_rec_clidname(dname, &clp->cl_name); status = nfs4_make_rec_clidname(dname, &clp->cl_name);
if (status) if (status)
return legacy_recdir_name_error(status); return legacy_recdir_name_error(clp, status);
status = nfs4_save_creds(&original_cred); status = nfs4_save_creds(&original_cred);
if (status < 0) if (status < 0)
...@@ -341,7 +339,7 @@ nfsd4_remove_clid_dir(struct nfs4_client *clp) ...@@ -341,7 +339,7 @@ nfsd4_remove_clid_dir(struct nfs4_client *clp)
status = nfs4_make_rec_clidname(dname, &clp->cl_name); status = nfs4_make_rec_clidname(dname, &clp->cl_name);
if (status) if (status)
return legacy_recdir_name_error(status); return legacy_recdir_name_error(clp, status);
status = mnt_want_write_file(nn->rec_file); status = mnt_want_write_file(nn->rec_file);
if (status) if (status)
...@@ -601,7 +599,7 @@ nfsd4_check_legacy_client(struct nfs4_client *clp) ...@@ -601,7 +599,7 @@ nfsd4_check_legacy_client(struct nfs4_client *clp)
status = nfs4_make_rec_clidname(dname, &clp->cl_name); status = nfs4_make_rec_clidname(dname, &clp->cl_name);
if (status) { if (status) {
legacy_recdir_name_error(status); legacy_recdir_name_error(clp, status);
return status; return status;
} }
......
...@@ -21,16 +21,6 @@ ...@@ -21,16 +21,6 @@
#include <linux/sunrpc/svcauth.h> #include <linux/sunrpc/svcauth.h>
#include "gss_rpc_xdr.h" #include "gss_rpc_xdr.h"
static bool gssx_check_pointer(struct xdr_stream *xdr)
{
__be32 *p;
p = xdr_reserve_space(xdr, 4);
if (unlikely(p == NULL))
return -ENOSPC;
return *p?true:false;
}
static int gssx_enc_bool(struct xdr_stream *xdr, int v) static int gssx_enc_bool(struct xdr_stream *xdr, int v)
{ {
__be32 *p; __be32 *p;
...@@ -264,25 +254,27 @@ static int gssx_dec_option_array(struct xdr_stream *xdr, ...@@ -264,25 +254,27 @@ static int gssx_dec_option_array(struct xdr_stream *xdr,
if (unlikely(p == NULL)) if (unlikely(p == NULL))
return -ENOSPC; return -ENOSPC;
count = be32_to_cpup(p++); count = be32_to_cpup(p++);
if (count != 0) { if (!count)
/* we recognize only 1 currently: CREDS_VALUE */ return 0;
oa->count = 1;
oa->data = kmalloc(sizeof(struct gssx_option), GFP_KERNEL); /* we recognize only 1 currently: CREDS_VALUE */
if (!oa->data) oa->count = 1;
return -ENOMEM;
creds = kmalloc(sizeof(struct svc_cred), GFP_KERNEL); oa->data = kmalloc(sizeof(struct gssx_option), GFP_KERNEL);
if (!creds) { if (!oa->data)
kfree(oa->data); return -ENOMEM;
return -ENOMEM;
}
oa->data[0].option.data = CREDS_VALUE; creds = kmalloc(sizeof(struct svc_cred), GFP_KERNEL);
oa->data[0].option.len = sizeof(CREDS_VALUE); if (!creds) {
oa->data[0].value.data = (void *)creds; kfree(oa->data);
oa->data[0].value.len = 0; return -ENOMEM;
} }
oa->data[0].option.data = CREDS_VALUE;
oa->data[0].option.len = sizeof(CREDS_VALUE);
oa->data[0].value.data = (void *)creds;
oa->data[0].value.len = 0;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
gssx_buffer dummy = { 0, NULL }; gssx_buffer dummy = { 0, NULL };
u32 length; u32 length;
...@@ -800,6 +792,7 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp, ...@@ -800,6 +792,7 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp,
struct xdr_stream *xdr, struct xdr_stream *xdr,
struct gssx_res_accept_sec_context *res) struct gssx_res_accept_sec_context *res)
{ {
u32 value_follows;
int err; int err;
/* res->status */ /* res->status */
...@@ -808,7 +801,10 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp, ...@@ -808,7 +801,10 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp,
return err; return err;
/* res->context_handle */ /* res->context_handle */
if (gssx_check_pointer(xdr)) { err = gssx_dec_bool(xdr, &value_follows);
if (err)
return err;
if (value_follows) {
err = gssx_dec_ctx(xdr, res->context_handle); err = gssx_dec_ctx(xdr, res->context_handle);
if (err) if (err)
return err; return err;
...@@ -817,7 +813,10 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp, ...@@ -817,7 +813,10 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp,
} }
/* res->output_token */ /* res->output_token */
if (gssx_check_pointer(xdr)) { err = gssx_dec_bool(xdr, &value_follows);
if (err)
return err;
if (value_follows) {
err = gssx_dec_buffer(xdr, res->output_token); err = gssx_dec_buffer(xdr, res->output_token);
if (err) if (err)
return err; return err;
...@@ -826,7 +825,10 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp, ...@@ -826,7 +825,10 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp,
} }
/* res->delegated_cred_handle */ /* res->delegated_cred_handle */
if (gssx_check_pointer(xdr)) { err = gssx_dec_bool(xdr, &value_follows);
if (err)
return err;
if (value_follows) {
/* we do not support upcall servers sending this data. */ /* we do not support upcall servers sending this data. */
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment