net/rxrpc/rxgk.c
Source file repositories/reference/linux-study-clean/net/rxrpc/rxgk.c
File Facts
- System
- Linux kernel
- Corpus path
net/rxrpc/rxgk.c- Extension
.c- Size
- 34434 bytes
- Lines
- 1356
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/net.hlinux/skbuff.hlinux/slab.hlinux/key-type.har-internal.hrxgk_common.h
Detected Declarations
function Copyrightfunction rxgk_free_server_keyfunction rxgk_free_preparse_server_keyfunction rxgk_destroy_server_keyfunction rxgk_describe_server_keyfunction rxgk_init_connection_securityfunction rxgk_free_call_cryptofunction modefunction packetfunction rxgk_secure_packetfunction modefunction packetfunction subpacketfunction rxgk_issue_challengefunction rxgk_validate_challengefunction rxgk_kernel_query_challengefunction rxgk_challenge_to_recvmsgfunction rxgk_pad_outfunction rxgk_insert_response_headerfunction rxgk_construct_authenticatorfunction rxgk_encrypt_authenticatorfunction rxgk_construct_responsefunction rxgk_respond_to_challengefunction rxgk_respond_to_challenge_no_appdatafunction rxgk_kernel_respond_to_challengefunction sendmsgfunction for_each_cmsghdrfunction rxgk_verify_authenticatorfunction rxgk_verify_responsefunction rxgk_clearfunction rxgk_initfunction rxgk_exitexport rxgk_kernel_query_challengeexport rxgk_kernel_respond_to_challenge
Annotated Snippet
ntohl(hdr->data_len) > len) {
ret = rxrpc_abort_eproto(call, skb, RXGK_SEALEDINCON,
rxgk_abort_2_short_data);
goto error;
}
call->rx_dec_offset = offset;
call->rx_dec_len = ntohl(hdr->data_len);
ret = 0;
error:
rxgk_put(gk);
_leave(" = %d", ret);
return ret;
}
/*
* Verify the security on a received packet or subpacket (if part of a
* jumbo packet).
*/
static int rxgk_verify_packet(struct rxrpc_call *call, struct sk_buff *skb)
{
struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
struct rxgk_context *gk;
u16 key_number = sp->hdr.cksum;
_enter("{%d{%x}},{#%u}",
call->debug_id, key_serial(call->conn->key), sp->hdr.seq);
gk = rxgk_get_key(call->conn, &key_number);
if (IS_ERR(gk)) {
switch (PTR_ERR(gk)) {
case -ESTALE:
return rxrpc_abort_eproto(call, skb, RXGK_BADKEYNO,
rxgk_abort_bad_key_number);
default:
return PTR_ERR(gk);
}
}
call->security_enctype = gk->krb5->etype;
switch (call->conn->security_level) {
case RXRPC_SECURITY_PLAIN:
rxgk_put(gk);
return 0;
case RXRPC_SECURITY_AUTH:
return rxgk_verify_packet_integrity(call, gk, skb);
case RXRPC_SECURITY_ENCRYPT:
return rxgk_verify_packet_encrypted(call, gk, skb);
default:
rxgk_put(gk);
return -ENOANO;
}
}
/*
* Allocate memory to hold a challenge or a response packet. We're not running
* in the io_thread, so we can't use ->tx_alloc.
*/
static struct page *rxgk_alloc_packet(size_t total_len)
{
gfp_t gfp = GFP_NOFS;
int order;
order = get_order(total_len);
if (order > 0)
gfp |= __GFP_COMP;
return alloc_pages(gfp, order);
}
/*
* Issue a challenge.
*/
static int rxgk_issue_challenge(struct rxrpc_connection *conn)
{
struct rxrpc_wire_header *whdr;
struct bio_vec bvec[1];
struct msghdr msg;
struct page *page;
size_t len = sizeof(*whdr) + sizeof(conn->rxgk.nonce);
u32 serial;
int ret;
_enter("{%d}", conn->debug_id);
get_random_bytes(&conn->rxgk.nonce, sizeof(conn->rxgk.nonce));
/* We can't use conn->tx_alloc without a lock */
page = rxgk_alloc_packet(sizeof(*whdr) + sizeof(conn->rxgk.nonce));
if (!page)
return -ENOMEM;
Annotation
- Immediate include surface: `linux/net.h`, `linux/skbuff.h`, `linux/slab.h`, `linux/key-type.h`, `ar-internal.h`, `rxgk_common.h`.
- Detected declarations: `function Copyright`, `function rxgk_free_server_key`, `function rxgk_free_preparse_server_key`, `function rxgk_destroy_server_key`, `function rxgk_describe_server_key`, `function rxgk_init_connection_security`, `function rxgk_free_call_crypto`, `function mode`, `function packet`, `function rxgk_secure_packet`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.