cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: 王明-软件底层技术部 <machel@vivo.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] 回复:  [PATCH v1] fs:dlm:Fix NULL pointer dereference bug in accept_from_sock()
Date: Wed, 5 Jul 2023 01:16:49 +0000	[thread overview]
Message-ID: <SG2PR06MB37431CA356AFA63FDF67EFAABD2FA@SG2PR06MB3743.apcprd06.prod.outlook.com> (raw)
In-Reply-To: <CAK-6q+jQcyyAtMD5tjzjrJg8Auy6HuugJomiSokwRhqRifVpCA@mail.gmail.com>

Thank you. I see. I hadn't noticed what the add_sock() function did before, but now I understand that newcon->sock will not be a null pointer.

-----????-----
???: Alexander Aring <aahringo@redhat.com> 
????: 2023?7?5? 0:22
???: ??-??????? <machel@vivo.com>
??: Christine Caulfield <ccaulfie@redhat.com>; David Teigland <teigland@redhat.com>; cluster-devel at redhat.com; linux-kernel at vger.kernel.org; opensource.kernel <opensource.kernel@vivo.com>
??: Re: [Cluster-devel] [PATCH v1] fs:dlm:Fix NULL pointer dereference bug in accept_from_sock()

[????????? aahringo at redhat.com ????????? https://aka.ms/LearnAboutSenderIdentification?????????????]

Hi,

On Tue, Jul 4, 2023 at 6:56?AM Wang Ming <machel@vivo.com> wrote:
>
> newcon -> sock is NULL but dereferenced.
> First check newcon. Whether sock is a null pointer.
> If so, the subsequent operations are skipped.
> If it is not empty, perform subsequent operations.
>

did you experience some null pointer dereference? If so, on which kernel was it?

> Signed-off-by: Wang Ming <machel@vivo.com>
> ---
>  fs/dlm/lowcomms.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c index 
> 9f14ea9f6..ea18b9478 100644
> --- a/fs/dlm/lowcomms.c
> +++ b/fs/dlm/lowcomms.c
> @@ -1081,9 +1081,12 @@ static int accept_from_sock(void)
>                 add_sock(newsock, newcon);
>

Here in add_sock() we assign newcon->sock = newsock. It cannot fail and newsock cannot be null, so holding the newcon->sock_lock write protected _should_ be safe that others don't manipulate newcon->sock.
It should, that's why I am asking if you experienced some issue here?

>                 /* check if we receved something while adding */
> -               lock_sock(newcon->sock->sk);
> -               lowcomms_queue_rwork(newcon);
> -               release_sock(newcon->sock->sk);

see above, newcon->sock should always be set at this point.

> +               if (newcon->sock) {
> +                       lock_sock(newcon->sock->sk);
> +                       lowcomms_queue_rwork(newcon);
> +                       release_sock(newcon->sock->sk);
> +               }
> +
>         }
>         up_write(&newcon->sock_lock);
>         srcu_read_unlock(&connections_srcu, idx);

- Alex


      reply	other threads:[~2023-07-05  1:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-04 10:47 [Cluster-devel] [PATCH v1] fs:dlm:Fix NULL pointer dereference bug in accept_from_sock() Wang Ming
2023-07-04 16:22 ` Alexander Aring
2023-07-05  1:16   ` 王明-软件底层技术部 [this message]

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=SG2PR06MB37431CA356AFA63FDF67EFAABD2FA@SG2PR06MB3743.apcprd06.prod.outlook.com \
    --to=machel@vivo.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).