All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter via Ocfs2-devel <ocfs2-devel@oss.oracle.com>
To: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Jakob Koschel <jakobkoschel@gmail.com>, ocfs2-devel@oss.oracle.com
Subject: Re: [Ocfs2-devel] [bug report] ocfs2/dlm: Fix race in adding/removing lockres' to/from the tracking list
Date: Thu, 10 Mar 2022 16:39:18 +0300	[thread overview]
Message-ID: <20220310133918.GH3315@kadam> (raw)
In-Reply-To: <5a5933bb-3078-2cfa-9403-a6b497199449@linux.alibaba.com>

On Thu, Mar 10, 2022 at 11:13:05AM +0800, Joseph Qi wrote:
> >>>     557         }
> >>>     558 
> >>>     559         list_for_each_entry(res, track_list, tracking) {
> >>>     560                 if (&res->tracking == &dlm->tracking_list)
> >>>                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >>> This should never be possible.  How is it possible?  If
> >>> &dlm->tracking_list is the list head the it's not possible without
> >>> memory corruption.  If &oldres->tracking is the list head then I do not
> >>> see how it is possible without memory corruption.  We can't mix different
> >>> types of list entries on the same list head?>
> >> In case of oldres, and the iterator points to dlm_ctxt.
> >> In this case, the lockres is not a valid one.
> > 
> > That doesn't make sense.  :/  This condition is doing pointer math.
> > The offset of ->tracking is 136 bytes and ->tracking list is 88 bytes
> > into the dlm struct.
> > 
> Now track_list is oldres->tracking, which is already linked to
> dlm->tracking_list?

Are you saying or are you guessing?  :P

It's not impossible to set this condition up so that it's true.  But
it's bug if someone does that.

I really think that condition can be deleted.  If you look at the commit
which added it b0d4f817ba5d ("ocfs2/dlm: Fix race in adding/removing
lockres' to/from the tracking list") the it's easy to imagine that it
was a copy and pasted pasted by mistake.

Or another possibility is that it was debug code that was committed
accidentally.  After all if you remove the locking a delete the last
entry at the right time then it would be easy enough for the condition
to be true.  Hopefully, these days the locking prevents that condition
from being possible.

regards,
dan carpenter

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

  reply	other threads:[~2022-03-10 13:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-07 14:51 [Ocfs2-devel] [bug report] ocfs2/dlm: Fix race in adding/removing lockres' to/from the tracking list Dan Carpenter via Ocfs2-devel
2022-03-09  7:46 ` Joseph Qi via Ocfs2-devel
2022-03-09 14:57   ` Dan Carpenter via Ocfs2-devel
2022-03-10  3:13     ` Joseph Qi via Ocfs2-devel
2022-03-10 13:39       ` Dan Carpenter via Ocfs2-devel [this message]
2022-03-11  1:50         ` Joseph Qi via Ocfs2-devel
2022-03-11  3:08           ` Joseph Qi via Ocfs2-devel

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=20220310133918.GH3315@kadam \
    --to=ocfs2-devel@oss.oracle.com \
    --cc=dan.carpenter@oracle.com \
    --cc=jakobkoschel@gmail.com \
    --cc=joseph.qi@linux.alibaba.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.