Re: BUG: unable to handle page fault for address, with ipv6.disable=1

From: Roberto Ricci
Date: Thu Sep 15 2022 - 19:42:01 EST


On 2022-09-14 Wed 18:47:12 +0300, Ido Schimmel wrote:
> This is most likely caused by commit 0daf07e52709 ("raw: convert raw
> sockets to RCU") which is being back ported to stable kernels.
>
> It made the initialization of 'raw_v6_hashinfo' conditional on IPv6
> being enabled. Can you try the following patch (works on my end)?
>
> diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
> index 19732b5dce23..d40b7d60e00e 100644
> --- a/net/ipv6/af_inet6.c
> +++ b/net/ipv6/af_inet6.c
> @@ -1072,13 +1072,13 @@ static int __init inet6_init(void)
> for (r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r)
> INIT_LIST_HEAD(r);
>
> + raw_hashinfo_init(&raw_v6_hashinfo);
> +
> if (disable_ipv6_mod) {
> pr_info("Loaded, but administratively disabled, reboot required to enable\n");
> goto out;
> }
>
> - raw_hashinfo_init(&raw_v6_hashinfo);
> -
> err = proto_register(&tcpv6_prot, 1);
> if (err)
> goto out;
>
> Another approach is the following, but I prefer the first:
>
> diff --git a/net/ipv4/raw_diag.c b/net/ipv4/raw_diag.c
> index 999321834b94..4fbdd69a2be8 100644
> --- a/net/ipv4/raw_diag.c
> +++ b/net/ipv4/raw_diag.c
> @@ -20,7 +20,7 @@ raw_get_hashinfo(const struct inet_diag_req_v2 *r)
> if (r->sdiag_family == AF_INET) {
> return &raw_v4_hashinfo;
> #if IS_ENABLED(CONFIG_IPV6)
> - } else if (r->sdiag_family == AF_INET6) {
> + } else if (r->sdiag_family == AF_INET6 && ipv6_mod_enabled()) {
> return &raw_v6_hashinfo;
> #endif
> } else {

Both the solutions you proposed work for me. Thanks.