aboutsummaryrefslogtreecommitdiff
path: root/net
AgeCommit message (Collapse)AuthorFilesLines
2023-02-20SUNRPC: Set rq_accept_statp inside ->accept methodsChuck Lever3-13/+16
To navigate around the space that svcauth_gss_accept() reserves for the RPC payload body length and sequence number fields, svcauth_gss_release() does a little dance with the reply's accept_stat, moving the accept_stat value in the response buffer down by two words. Instead, let's have the ->accept() methods each set the proper final location of the accept_stat to avoid having to move things. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Refactor RPC server dispatch methodChuck Lever1-5/+5
Currently, svcauth_gss_accept() pre-reserves response buffer space for the RPC payload length and GSS sequence number before returning to the dispatcher, which then adds the header's accept_stat field. The problem is the accept_stat field is supposed to go before the length and seq_num fields. So svcauth_gss_release() has to relocate the accept_stat value (see svcauth_gss_prepare_to_wrap()). To enable these fields to be added to the response buffer in the correct (final) order, the pointer to the accept_stat has to be made available to svcauth_gss_accept() so that it can set it before reserving space for the length and seq_num fields. As a first step, move the pointer to the location of the accept_stat field into struct svc_rqst. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Final clean-up of svc_process_common()Chuck Lever1-8/+6
The @resv parameter is no longer used. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Convert RPC Reply header encoding to use xdr_streamChuck Lever1-25/+25
The main part of RPC header encoding and the formation of error responses are now done using the xdr_stream helpers. Bounds checking before each XDR data item is encoded makes the server's encoding path safer against accidental buffer overflows. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Hoist init_encode out of svc_authenticate()Chuck Lever3-5/+2
Now that each ->accept method has been converted, the svcxdr_init_encode() calls can be hoisted back up into the generic RPC server code. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Use xdr_stream for encoding GSS reply verifiersChuck Lever1-73/+8
Done as part of hardening the server-side RPC header encoding path. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Use xdr_stream to encode replies in server-side GSS upcall helpersChuck Lever1-54/+90
This code constructs replies to the decorated NULL procedure calls that establish GSS contexts. Convert this code path to use struct xdr_stream to encode such responses. Done as part of hardening the server-side RPC header encoding path. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Convert unwrap data paths to use xdr_stream for repliesChuck Lever1-10/+8
We're now moving svcxdr_init_encode() to /before/ the flavor's ->accept method has set rq_auth_slack. Add a helper that can set rq_auth_slack /after/ svcxdr_init_encode() has been called. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Use xdr_stream to encode Reply verifier in svcauth_tls_accept()Chuck Lever1-9/+13
Done as part of hardening the server-side RPC header encoding path. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Use xdr_stream to encode Reply verifier in svcauth_unix_accept()Chuck Lever1-5/+4
Done as part of hardening the server-side RPC header encoding path. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Use xdr_stream to encode Reply verifier in svcauth_null_accept()Chuck Lever1-5/+4
Done as part of hardening the server-side RPC header encoding path. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Move svcxdr_init_encode() into ->accept methodsChuck Lever3-4/+10
Refactor: So that the overhaul of each ->accept method can be done in separate smaller patches, temporarily move the svcxdr_init_encode() call into those methods. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Push svcxdr_init_encode() into svc_process_common()Chuck Lever1-0/+1
Now that all vs_dispatch functions invoke svcxdr_init_encode(), it is common code and can be pushed down into the generic RPC server. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Add XDR encoding helper for opaque_authChuck Lever1-0/+29
RFC 5531 defines an MSG_ACCEPTED Reply message like this: struct accepted_reply { opaque_auth verf; union switch (accept_stat stat) { case SUCCESS: ... In the current server code, struct opaque_auth encoding is open- coded. Introduce a helper that encodes an opaque_auth data item within the context of a xdr_stream. Done as part of hardening the server-side RPC header decoding and encoding paths. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Remove the rpc_stat variable in svc_process_common()Chuck Lever1-13/+11
There's no RPC header field called rpc_stat; more precisely, the variable appears to be recording an accept_stat value. But it looks like we don't need to preserve this value at all, actually, so simply remove the variable. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Check rq_auth_stat when preparing to wrap a responseChuck Lever1-5/+7
Commit 5b304bc5bfcc ("[PATCH] knfsd: svcrpc: gss: fix failure on SVC_DENIED in integrity case") added a check to prevent wrapping an RPC response if reply_stat == MSG_DENIED, assuming that the only way to get to svcauth_gss_release() with that reply_stat value was if the reject_stat was AUTH_ERROR (reject_stat == MISMATCH is handled earlier in svc_process_common()). The code there is somewhat confusing. For one thing, rpc_success is an accept_stat value, not a reply_stat value. The correct reply_stat value to look for is RPC_MSG_DENIED. It happens to be the same value as rpc_success, so it all works out, but it's not terribly readable. Since commit 438623a06bac ("SUNRPC: Add svc_rqst::rq_auth_stat"), the actual auth_stat value is stored in the svc_rqst, so that value is now available to svcauth_gss_prepare_to_wrap() to make its decision to wrap, based on direct information about the authentication status of the RPC caller. No behavior change is intended, this simply replaces some old code with something that should be more self-documenting. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Convert svcauth_gss_wrap_priv() to use xdr_stream()Chuck Lever1-5/+10
Actually xdr_stream does not add value here because of how gss_wrap() works. This is just a clean-up patch. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Add @head and @tail variables in svcauth_gss_wrap_priv()Chuck Lever1-17/+17
Simplify the references to the head and tail iovecs for readability. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Record gss_wrap() errors in svcauth_gss_wrap_priv()Chuck Lever1-10/+19
Match the error reporting in the other unwrap and wrap functions. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Rename automatic variables in svcauth_gss_wrap_resp_priv()Chuck Lever1-30/+42
Clean up variable names to match the other unwrap and wrap functions. Additionally, the explicit type cast on @gsd in unnecessary; and @resbuf is renamed to match the variable naming in the unwrap functions. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Convert svcauth_gss_wrap_integ() to use xdr_stream()Chuck Lever1-13/+12
Done as part of hardening the server-side RPC header decoding path. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Replace checksum construction in svcauth_gss_wrap_integ()Chuck Lever1-9/+2
Replace finicky logic: Instead of trying to find scratch space in the response buffer, use the scratch buffer from struct gss_svc_data. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Record gss_get_mic() errors in svcauth_gss_wrap_integ()Chuck Lever1-13/+13
An error computing the checksum here is an exceptional event. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Rename automatic variables in svcauth_gss_wrap_resp_integ()Chuck Lever1-27/+43
Clean up: To help orient readers, name the stack variables to match the XDR field names. Additionally, the explicit type cast on @gsd is unnecessary; and @resbuf is renamed to match the variable naming in the unwrap functions. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Clean up svcauth_gss_release()Chuck Lever1-14/+16
Now that upper layers use an xdr_stream to track the construction of each RPC Reply message, resbuf->len is kept up-to-date automatically. There's no need to recompute it in svc_gss_release(). Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Hoist svcxdr_init_decode() into svc_process()Chuck Lever2-12/+17
Now the entire RPC Call header parsing path is handled via struct xdr_stream-based decoders. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Remove svc_process_common's argv parameterChuck Lever1-5/+5
Clean up: With xdr_stream decoding, the @argv parameter is no longer used. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Decode most of RPC header with xdr_streamChuck Lever1-11/+9
Done as part of hardening the server-side RPC header decoding path. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Eliminate unneeded variableChuck Lever1-4/+4
Clean up: Saving the RPC program number in two places is unnecessary. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Re-order construction of the first reply fieldsChuck Lever1-7/+3
Clean up: Group these together for legibility. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Hoist init_decode out of svc_authenticate()Chuck Lever4-13/+9
Now that each ->accept method has been converted to use xdr_stream, the svcxdr_init_decode() calls can be hoisted back up into the generic RPC server code. The dprintk in svc_authenticate() is removed, since trace_svc_authenticate() reports the same information. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Convert the svcauth_gss_accept() pre-amble to use xdr_streamChuck Lever1-50/+75
Done as part of hardening the server-side RPC header decoding path. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Clean up svcauth_gss_accept's NULL procedure checkChuck Lever1-5/+9
Micro-optimizations: 1. The value of rqstp->rq_auth_stat is replaced no matter which arm of the switch is taken, so the initial assignment can be safely removed. 2. Avoid checking the value of gc->gc_proc twice in the I/O (RPC_GSS_PROC_DATA) path. The cost is a little extra code redundancy. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Convert gss_verify_header() to use xdr_streamChuck Lever1-23/+29
Done as part of hardening the server-side RPC header decoding path. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Convert unwrap_priv_data() to use xdr_streamChuck Lever2-51/+21
Done as part of hardening the server-side RPC header decoding path. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Rename automatic variables in unwrap_priv_data()Chuck Lever1-13/+25
Clean up: To help orient readers, name the stack variables to match the XDR field names. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Convert unwrap_integ_data() to use xdr_streamChuck Lever2-16/+46
Done as part of hardening the server-side RPC header decoding path. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Rename automatic variables in unwrap_integ_data()Chuck Lever1-24/+33
Clean up: To help orient readers, name the stack variables to match the XDR field names. For readability, I'm also going to rename the unwrap and wrap functions in a consistent manner, starting with unwrap_integ_data(). Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Replace read_u32_from_xdr_buf() with existing XDR helperChuck Lever1-15/+1
Clean up / code de-duplication - this functionality is already available in the generic XDR layer. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Convert server-side GSS upcall helpers to use xdr_streamChuck Lever1-29/+58
The entire RPC_GSS_PROC_INIT path is converted over to xdr_stream for decoding the Call credential and verifier. Done as part of hardening the server-side RPC header decoding path. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Remove gss_read_verf()Chuck Lever1-26/+11
gss_read_verf() is already short. Fold it into its only caller. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Remove gss_read_common_verf()Chuck Lever1-21/+5
gss_read_common_verf() is now just a wrapper for dup_netobj(), thus it can be replaced with direct calls to dup_netobj(). Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Hoist common verifier decoding code into svcauth_gss_proc_init()Chuck Lever1-12/+14
Pre-requisite to replacing gss_read_common_verf(). Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Move the server-side GSS upcall to a noinline functionChuck Lever1-4/+9
Since upcalls are infrequent, ensure the compiler places the upcall mechanism out-of-line from the I/O path. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Convert svcauth_tls_accept() to use xdr_streamChuck Lever1-11/+26
Done as part of hardening the server-side RPC header decoding path. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Convert svcauth_unix_accept() to use xdr_streamChuck Lever1-20/+51
Done as part of hardening the server-side RPC header decoding path. Since the server-side of the Linux kernel SunRPC implementation ignores the contents of the Call's machinename field, there's no need for its RPC_AUTH_UNIX authenticator to reject names that are larger than UNX_MAXNODENAME. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Convert svcauth_null_accept() to use xdr_streamChuck Lever1-8/+25
Done as part of hardening the server-side RPC header decoding path. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Add an XDR decoding helper for struct opaque_authChuck Lever1-0/+28
RFC 5531 defines the body of an RPC Call message like this: struct call_body { unsigned int rpcvers; unsigned int prog; unsigned int vers; unsigned int proc; opaque_auth cred; opaque_auth verf; /* procedure-specific parameters start here */ }; In the current server code, decoding a struct opaque_auth type is open-coded in several places, and is thus difficult to harden everywhere. Introduce a helper for decoding an opaque_auth within the context of a xdr_stream. This helper can be shared with all authentication flavor implemenations, even on the client-side. Done as part of hardening the server-side RPC header decoding paths. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Move svcxdr_init_decode() into ->accept methodsChuck Lever3-1/+8
Refactor: So that the overhaul of each ->accept method can be done in separate smaller patches, temporarily move the svcxdr_init_decode() call into those methods. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
2023-02-20SUNRPC: Push svcxdr_init_decode() into svc_process_common()Chuck Lever1-0/+1
Now that all vs_dispatch functions invoke svcxdr_init_decode(), it is common code and can be pushed down into the generic RPC server. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>