net/sysctl_net.c
Source file repositories/reference/linux-study-clean/net/sysctl_net.c
File Facts
- System
- Linux kernel
- Corpus path
net/sysctl_net.c- Extension
.c- Size
- 4566 bytes
- Lines
- 180
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/mm.hlinux/export.hlinux/sysctl.hlinux/nsproxy.hnet/sock.hnet/ip.hlinux/if_ether.h
Detected Declarations
function net_ctl_header_lookupfunction is_seenfunction net_ctl_permissionsfunction net_ctl_set_ownershipfunction sysctl_net_initfunction sysctl_net_exitfunction net_sysctl_initfunction ensure_safe_net_sysctlfunction unregister_net_sysctl_tableexport register_net_sysctl_szexport unregister_net_sysctl_table
Annotated Snippet
if ((ent->mode & 0222) == 0) {
pr_debug(" Not writable by anyone\n");
continue;
}
/* Where does data point? */
addr = (unsigned long)ent->data;
if (is_module_address(addr))
where = "module";
else if (is_kernel_core_data(addr))
where = "kernel";
else
continue;
/* If it is writable and points to kernel/module global
* data, then it's probably a netns leak.
*/
WARN(1, "sysctl %s/%s: data points to %s global data: %ps\n",
path, ent->procname, where, ent->data);
/* Make it "safe" by dropping writable perms */
ent->mode &= ~0222;
}
}
struct ctl_table_header *register_net_sysctl_sz(struct net *net,
const char *path,
struct ctl_table *table,
size_t table_size)
{
if (!net_eq(net, &init_net))
ensure_safe_net_sysctl(net, path, table, table_size);
return __register_sysctl_table(&net->sysctls, path, table, table_size);
}
EXPORT_SYMBOL_GPL(register_net_sysctl_sz);
void unregister_net_sysctl_table(struct ctl_table_header *header)
{
unregister_sysctl_table(header);
}
EXPORT_SYMBOL_GPL(unregister_net_sysctl_table);
Annotation
- Immediate include surface: `linux/mm.h`, `linux/export.h`, `linux/sysctl.h`, `linux/nsproxy.h`, `net/sock.h`, `net/ip.h`, `linux/if_ether.h`.
- Detected declarations: `function net_ctl_header_lookup`, `function is_seen`, `function net_ctl_permissions`, `function net_ctl_set_ownership`, `function sysctl_net_init`, `function sysctl_net_exit`, `function net_sysctl_init`, `function ensure_safe_net_sysctl`, `function unregister_net_sysctl_table`, `export register_net_sysctl_sz`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
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.