From: Remi Pommarel <repk@triplefau.lt>
To: Antonio Quartulli <a@unstable.cc>
Cc: b.a.t.m.a.n@lists.open-mesh.org,
Marek Lindner <mareklindner@neomailbox.ch>,
Simon Wunderlich <sw@simonwunderlich.de>,
Sven Eckelmann <sven@narfation.org>
Subject: Re: [PATCH v3 1/5] batman-adv: Do not send uninitialized TT changes
Date: Thu, 21 Nov 2024 16:07:24 +0100 [thread overview]
Message-ID: <Zz9MrP6LBw0eY_Uv@pilgrim> (raw)
In-Reply-To: <Zz88AYyDTv5W9gQk@pilgrim>
On Thu, Nov 21, 2024 at 02:56:17PM +0100, Remi Pommarel wrote:
> On Thu, Nov 21, 2024 at 02:05:58PM +0100, Antonio Quartulli wrote:
> > On 20/11/2024 18:47, Remi Pommarel wrote:
> > > The number of TT changes can be less than initially expected in
> > > batadv_tt_tvlv_container_update() (changes can be removed by
> > > batadv_tt_local_event() in ADD+DEL sequence between reading
> > > tt_diff_entries_num and actually iterating the change list under lock).
> > >
> > > Thus tt_diff_len could be bigger than the actual changes size that need
> > > to be sent. Because batadv_send_my_tt_response sends the whole
> > > packet, uninitialized data can be interpreted as TT changes on other
> > > nodes leading to weird TT global entries on those nodes such as:
> > >
> > > * 00:00:00:00:00:00 -1 [....] ( 0) 88:12:4e:ad:7e:ba (179) (0x45845380)
> > > * 00:00:00:00:78:79 4092 [.W..] ( 0) 88:12:4e:ad:7e:3c (145) (0x8ebadb8b)
> > >
> > > All of the above also applies to OGM tvlv container buffer's tvlv_len.
> > >
> > > Remove the extra allocated space to avoid sending uninitialized TT
> > > changes in batadv_send_my_tt_response() and batadv_v_ogm_send_softif().
> > >
> > > Fixes: e1bf0c14096f ("batman-adv: tvlv - convert tt data sent within OGMs")
> > > Signed-off-by: Remi Pommarel <repk@triplefau.lt>
> > > ---
> > > net/batman-adv/translation-table.c | 7 +++++++
> > > 1 file changed, 7 insertions(+)
> > >
> > > diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
> > > index 2243cec18ecc..f0590f9bc2b1 100644
> > > --- a/net/batman-adv/translation-table.c
> > > +++ b/net/batman-adv/translation-table.c
> > > @@ -990,6 +990,7 @@ static void batadv_tt_tvlv_container_update(struct batadv_priv *bat_priv)
> > > int tt_diff_len, tt_change_len = 0;
> > > int tt_diff_entries_num = 0;
> > > int tt_diff_entries_count = 0;
> > > + size_t tt_extra_len = 0;
> > > u16 tvlv_len;
> > > tt_diff_entries_num = atomic_read(&bat_priv->tt.local_changes);
> > > @@ -1027,6 +1028,9 @@ static void batadv_tt_tvlv_container_update(struct batadv_priv *bat_priv)
> > > }
> > > spin_unlock_bh(&bat_priv->tt.changes_list_lock);
> >
> > what speaks against acquiring tt.changes_list_lock before reading
> > tt.local_changes? (and making sure the writer does the update under lock
> > too) Any reason for not pursuing that path?
>
> Nothing against, just tried to follow old behavior in case this was
> that way for performance reasons. That would mean
> batadv_tt_local_commit_changes_nolock() to take the lock; because it
> is only called once per OGM interval I think that would be ok.
Actually I initialy though that holding this lock in
batadv_tt_local_commit_changes_nolock() would be fine, but because it
purges client and updates crc (two fairly intensive operations), that
could be a bad idea to hold the lock that long.
So batadv_tt_local_commit_changes_nolock() would still need to get
tt.local_changes without the lock (needing READ_ONCE), hence updates
would need WRITE_ONCE to avoid store tearing as discussed with Sven.
So the patch would be quite similar, only tt->tt.changes_list_lock will
be taken sooner in batadv_tt_tvlv_container_update().
That will fix the ADD between two read situation as you described
though.
Do you still prefer this option ?
Thanks
--
Remi
next prev parent reply other threads:[~2024-11-21 15:08 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-20 17:47 [PATCH v3 0/5] batman-adv: TT change events fixes and improvements Remi Pommarel
2024-11-20 17:47 ` [PATCH v3 1/5] batman-adv: Do not send uninitialized TT changes Remi Pommarel
2024-11-21 13:05 ` Antonio Quartulli
2024-11-21 13:56 ` Remi Pommarel
2024-11-21 15:07 ` Remi Pommarel [this message]
2024-11-21 18:02 ` Sven Eckelmann
2024-11-21 20:24 ` Remi Pommarel
2024-11-21 21:07 ` Antonio Quartulli
2024-11-22 8:16 ` Sven Eckelmann
2024-11-20 17:47 ` [PATCH v3 2/5] batman-adv: Remove uninitialized data in full table TT response Remi Pommarel
2024-11-21 13:14 ` Antonio Quartulli
2024-11-21 18:20 ` Sven Eckelmann
2024-11-21 20:55 ` Antonio Quartulli
2024-11-20 17:47 ` [PATCH v3 3/5] batman-adv: Do not let TT changes list grows indefinitely Remi Pommarel
2024-11-21 13:50 ` Antonio Quartulli
2024-11-21 14:18 ` Remi Pommarel
2024-11-20 17:47 ` [PATCH v3 4/5] batman-adv: Remove atomic usage for tt.local_changes Remi Pommarel
2024-11-21 9:04 ` Sven Eckelmann
2024-11-21 9:28 ` Remi Pommarel
2024-11-21 9:34 ` Sven Eckelmann
2024-11-20 17:47 ` [PATCH v3 5/5] batman-adv: Don't keep redundant TT change events Remi Pommarel
2024-11-21 8:43 ` Sven Eckelmann
2024-11-21 9:13 ` Remi Pommarel
2024-11-21 9:23 ` Sven Eckelmann
2024-11-21 9:30 ` Sven Eckelmann
2024-11-21 9:35 ` Remi Pommarel
2024-11-20 19:46 ` [PATCH v3 0/5] batman-adv: TT change events fixes and improvements Sven Eckelmann
2024-11-20 19:54 ` Remi Pommarel
2024-11-20 20:29 ` Antonio Quartulli
2024-11-20 21:04 ` Sven Eckelmann
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=Zz9MrP6LBw0eY_Uv@pilgrim \
--to=repk@triplefau.lt \
--cc=a@unstable.cc \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
--cc=mareklindner@neomailbox.ch \
--cc=sven@narfation.org \
--cc=sw@simonwunderlich.de \
/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.