mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google.com>
To: YueHaibing <yuehaibing@huawei.com>
Cc: David Miller <davem@davemloft.net>,
	Willem de Bruijn <willemb@google.com>,
	LKML <linux-kernel@vger.kernel.org>,
	netdev <netdev@vger.kernel.org>,
	maximmi@mellanox.com
Subject: Re: [PATCH] packet: Fix error path in packet_init
Date: Wed, 8 May 2019 08:50:03 -0700	[thread overview]
Message-ID: <CANn89iLbFa2fbJ5zQ_BOWEMUbk1aSWQHHbdEBU7DdfvpvEOiDg@mail.gmail.com> (raw)
In-Reply-To: <20190508153241.30776-1-yuehaibing@huawei.com>

On Wed, May 8, 2019 at 8:33 AM YueHaibing <yuehaibing@huawei.com> wrote:
>
>  kernel BUG at lib/list_debug.c:47!
>  invalid opcode: 0000 [#1
>  CPU: 0 PID: 11195 Comm: rmmod Tainted: G        W         5.1.0+ #33
>  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org 04/01/2014
>  RIP: 0010:__list_del_entry_valid+0x55/0x90
>  Code: 12 48 39 d7 75 39 48 8b 50 08 48 39 d7 75 1d b8 01 00 00 00 5d c3 48 89 c2 48 89 fe
>  31 c0 48 c7 c7 40 3a fe 82 e8 74 c1 78 ff <0f> 0b 48 89 fe 31 c0 48 c7 c7 f0 3a fe 82 e8 61 c1 78 ff 0f 0b 48
>  RSP: 0018:ffffc90001b8be48 EFLAGS: 00010246
>  RAX: 000000000000004e RBX: ffffffffa0210000 RCX: 0000000000000000
>  RDX: 0000000000000000 RSI: ffff888237a16808 RDI: 00000000ffffffff
>  RBP: ffffc90001b8be48 R08: 0000000000000000 R09: 0000000000000001
>  R10: 0000000000000000 R11: ffffffff842c1640 R12: 0000000000000800
>  R13: 0000000000000000 R14: ffffc90001b8be58 R15: ffffffffa0210000
>  FS:  00007f58963c7540(0000) GS:ffff888237a00000(0000) knlGS:0000000000000000
>  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>  CR2: 000056064c7af818 CR3: 00000001e9895000 CR4: 00000000000006f0
>  Call Trace:
>   unregister_pernet_operations+0x34/0x110
>   unregister_pernet_subsys+0x1c/0x30
>   packet_exit+0x1c/0x1dd [af_packet
>   __x64_sys_delete_module+0x16b/0x290
>   ? trace_hardirqs_off_thunk+0x1a/0x1c
>   do_syscall_64+0x6b/0x1d0
>   entry_SYSCALL_64_after_hwframe+0x49/0xbe
>
> Fix error handing path in packet_init to
> avoid possilbe issue if some error occur.

The trace is about rmmod, and the patch is in packet_init() ?

So I believe we need more explanations of why you believe this patch
is fixing the issue
the bot hit .

Thanks.

>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  net/packet/af_packet.c | 26 +++++++++++++++++++++-----
>  1 file changed, 21 insertions(+), 5 deletions(-)
>
> diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
> index 90d4e3c..3917c75 100644
> --- a/net/packet/af_packet.c
> +++ b/net/packet/af_packet.c
> @@ -4598,14 +4598,30 @@ static void __exit packet_exit(void)
>
>  static int __init packet_init(void)
>  {
> -       int rc = proto_register(&packet_proto, 0);
> +       int rc;
>
> -       if (rc != 0)
> +       rc = proto_register(&packet_proto, 0);
> +       if (rc)
>                 goto out;
>
> -       sock_register(&packet_family_ops);
> -       register_pernet_subsys(&packet_net_ops);
> -       register_netdevice_notifier(&packet_netdev_notifier);
> +       rc = sock_register(&packet_family_ops);
> +       if (rc)
> +               goto out_proto;
> +       rc = register_pernet_subsys(&packet_net_ops);
> +       if (rc)
> +               goto out_sock;
> +       rc = register_netdevice_notifier(&packet_netdev_notifier);
> +       if (rc)
> +               goto out_pernet;
> +
> +       return 0;
> +
> +out_pernet:
> +       unregister_pernet_subsys(&packet_net_ops);
> +out_sock:
> +       sock_unregister(PF_PACKET);
> +out_proto:
> +       proto_unregister(&packet_proto);
>  out:
>         return rc;
>  }
> --
> 1.8.3.1
>
>

  reply	other threads:[~2019-05-08 15:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-08 15:32 YueHaibing
2019-05-08 15:50 ` Eric Dumazet [this message]
2019-05-09  2:48   ` YueHaibing
2019-05-09 14:52 ` [PATCH v2] " YueHaibing
2019-05-09 20:46   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANn89iLbFa2fbJ5zQ_BOWEMUbk1aSWQHHbdEBU7DdfvpvEOiDg@mail.gmail.com \
    --to=edumazet@google.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maximmi@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=willemb@google.com \
    --cc=yuehaibing@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®