Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH v2 0/2] replication: fix uninitialized replica_version_id access
@ 2021-09-02 13:21 Serge Petrenko via Tarantool-patches
  2021-09-02 13:21 ` [Tarantool-patches] [PATCH v2 1/2] box: remove unused variable in process_register() Serge Petrenko via Tarantool-patches
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Serge Petrenko via Tarantool-patches @ 2021-09-02 13:21 UTC (permalink / raw)
  To: v.shpilevoy, gorcunov; +Cc: tarantool-patches

https://github.com/tarantool/tarantool/tree/sp/version-uninitialized-access

Changes in v2
 - rework patch 2: instead of initializing version in process_subscribe(),
   reset all parameters to default values in xrow_decode_subscribe().

Serge Petrenko (2):
  box: remove unused variable in process_register()
  xrow: reset parameters of decode_subscribe() to default

 src/box/box.cc |  4 +---
 src/box/xrow.c | 13 +++++++++++--
 2 files changed, 12 insertions(+), 5 deletions(-)

-- 
2.30.1 (Apple Git-130)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Tarantool-patches] [PATCH v2 1/2] box: remove unused variable in process_register()
  2021-09-02 13:21 [Tarantool-patches] [PATCH v2 0/2] replication: fix uninitialized replica_version_id access Serge Petrenko via Tarantool-patches
@ 2021-09-02 13:21 ` Serge Petrenko via Tarantool-patches
  2021-09-02 13:21 ` [Tarantool-patches] [PATCH v2 2/2] xrow: reset parameters of decode_subscribe() to default Serge Petrenko via Tarantool-patches
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Serge Petrenko via Tarantool-patches @ 2021-09-02 13:21 UTC (permalink / raw)
  To: v.shpilevoy, gorcunov; +Cc: tarantool-patches

replica_version_id is unused in box_process_register,
so no point in filling it with anything coming from a remote instance.
Besides, version id isn't sent in register at all.

Follow-up #6034
---
 src/box/box.cc | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/box/box.cc b/src/box/box.cc
index 0b12b1328..2c8113cbb 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -2616,9 +2616,7 @@ box_process_register(struct ev_io *io, struct xrow_header *header)
 
 	struct tt_uuid instance_uuid = uuid_nil;
 	struct vclock replica_vclock;
-	uint32_t replica_version_id;
-	xrow_decode_register_xc(header, &instance_uuid, &replica_vclock,
-				&replica_version_id);
+	xrow_decode_register_xc(header, &instance_uuid, &replica_vclock, NULL);
 
 	if (!is_box_configured)
 		tnt_raise(ClientError, ER_LOADING);
-- 
2.30.1 (Apple Git-130)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Tarantool-patches] [PATCH v2 2/2] xrow: reset parameters of decode_subscribe() to default
  2021-09-02 13:21 [Tarantool-patches] [PATCH v2 0/2] replication: fix uninitialized replica_version_id access Serge Petrenko via Tarantool-patches
  2021-09-02 13:21 ` [Tarantool-patches] [PATCH v2 1/2] box: remove unused variable in process_register() Serge Petrenko via Tarantool-patches
@ 2021-09-02 13:21 ` Serge Petrenko via Tarantool-patches
  2021-09-02 21:47   ` Vladislav Shpilevoy via Tarantool-patches
  2021-09-02 17:34 ` [Tarantool-patches] [PATCH v2 0/2] replication: fix uninitialized replica_version_id access Cyrill Gorcunov via Tarantool-patches
  2021-09-09 10:18 ` Kirill Yukhin via Tarantool-patches
  3 siblings, 1 reply; 8+ messages in thread
From: Serge Petrenko via Tarantool-patches @ 2021-09-02 13:21 UTC (permalink / raw)
  To: v.shpilevoy, gorcunov; +Cc: tarantool-patches

Nullify all the output parameters passed to xrow_decode_subscribe().

This should help us get rid of cases when some of the parameters were
left uninitialized when the SUBSCRIBE request didn't contain the
corresponding fields.

Follow-up #6034
---
 src/box/xrow.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/box/xrow.c b/src/box/xrow.c
index 7df1af4ab..3cad2c1be 100644
--- a/src/box/xrow.c
+++ b/src/box/xrow.c
@@ -1561,10 +1561,19 @@ xrow_decode_subscribe(struct xrow_header *row, struct tt_uuid *replicaset_uuid,
 		return -1;
 	}
 
-	if (anon)
+	if (replicaset_uuid != NULL)
+		*replicaset_uuid = uuid_nil;
+	if (instance_uuid != NULL)
+		*instance_uuid = uuid_nil;
+	if (vclock != NULL)
+		vclock_create(vclock);
+	if (version_id != NULL)
+		*version_id = 0;
+	if (anon != NULL)
 		*anon = false;
-	if (id_filter)
+	if (id_filter != NULL)
 		*id_filter = 0;
+
 	d = data;
 	uint32_t map_size = mp_decode_map(&d);
 	for (uint32_t i = 0; i < map_size; i++) {
-- 
2.30.1 (Apple Git-130)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 0/2] replication: fix uninitialized replica_version_id access
  2021-09-02 13:21 [Tarantool-patches] [PATCH v2 0/2] replication: fix uninitialized replica_version_id access Serge Petrenko via Tarantool-patches
  2021-09-02 13:21 ` [Tarantool-patches] [PATCH v2 1/2] box: remove unused variable in process_register() Serge Petrenko via Tarantool-patches
  2021-09-02 13:21 ` [Tarantool-patches] [PATCH v2 2/2] xrow: reset parameters of decode_subscribe() to default Serge Petrenko via Tarantool-patches
@ 2021-09-02 17:34 ` Cyrill Gorcunov via Tarantool-patches
  2021-09-09 10:18 ` Kirill Yukhin via Tarantool-patches
  3 siblings, 0 replies; 8+ messages in thread
From: Cyrill Gorcunov via Tarantool-patches @ 2021-09-02 17:34 UTC (permalink / raw)
  To: Serge Petrenko; +Cc: v.shpilevoy, tarantool-patches

On Thu, Sep 02, 2021 at 04:21:32PM +0300, Serge Petrenko wrote:
> https://github.com/tarantool/tarantool/tree/sp/version-uninitialized-access
> 
> Changes in v2
>  - rework patch 2: instead of initializing version in process_subscribe(),
>    reset all parameters to default values in xrow_decode_subscribe().

Ack. Though I've been fine with v1 as well :)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 2/2] xrow: reset parameters of decode_subscribe() to default
  2021-09-02 13:21 ` [Tarantool-patches] [PATCH v2 2/2] xrow: reset parameters of decode_subscribe() to default Serge Petrenko via Tarantool-patches
@ 2021-09-02 21:47   ` Vladislav Shpilevoy via Tarantool-patches
  2021-09-06  8:06     ` Serge Petrenko via Tarantool-patches
  0 siblings, 1 reply; 8+ messages in thread
From: Vladislav Shpilevoy via Tarantool-patches @ 2021-09-02 21:47 UTC (permalink / raw)
  To: Serge Petrenko, gorcunov; +Cc: tarantool-patches

Hi! Thanks for the fixes!

Now you can drop:

	applier.cc:1256: cluster_id = uuid_nil;
	applier.cc:1292: vclock_create(&applier->remote_vclock_at_subscribe);

	box.cc:2617: instance_uuid = uuid_nil;
	box.cc:2850: replica_uuid = uuid_nil;
	box.cc:2851: peer_replicaset_uuid = uuid_nil;
	box.cc:2854: vclock_create(&replica_clock);

	relay.cc:687: vclock_create(&relay->recv_vclock);

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 2/2] xrow: reset parameters of decode_subscribe() to default
  2021-09-02 21:47   ` Vladislav Shpilevoy via Tarantool-patches
@ 2021-09-06  8:06     ` Serge Petrenko via Tarantool-patches
  2021-09-07 21:46       ` Vladislav Shpilevoy via Tarantool-patches
  0 siblings, 1 reply; 8+ messages in thread
From: Serge Petrenko via Tarantool-patches @ 2021-09-06  8:06 UTC (permalink / raw)
  To: Vladislav Shpilevoy, gorcunov; +Cc: tarantool-patches



03.09.2021 00:47, Vladislav Shpilevoy пишет:
> Hi! Thanks for the fixes!
>
> Now you can drop:
>
> 	applier.cc:1256: cluster_id = uuid_nil;
> 	applier.cc:1292: vclock_create(&applier->remote_vclock_at_subscribe);
>
> 	box.cc:2617: instance_uuid = uuid_nil;
> 	box.cc:2850: replica_uuid = uuid_nil;
> 	box.cc:2851: peer_replicaset_uuid = uuid_nil;
> 	box.cc:2854: vclock_create(&replica_clock);
>
> 	relay.cc:687: vclock_create(&relay->recv_vclock);
Hi!

Ok:

diff --git a/src/box/applier.cc b/src/box/applier.cc
index 9256078e1..b981bd436 100644
--- a/src/box/applier.cc
+++ b/src/box/applier.cc
@@ -1289,7 +1289,6 @@ applier_subscribe(struct applier *applier)
           * the replica, and replica has to check whether
           * its and master's cluster ids match.
           */
- vclock_create(&applier->remote_vclock_at_subscribe);
          xrow_decode_subscribe_response_xc(&row, &cluster_id,
                      &applier->remote_vclock_at_subscribe);
          applier->instance_id = row.replica_id;
diff --git a/src/box/box.cc b/src/box/box.cc
index 2c8113cbb..c5797fe58 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -2614,7 +2614,7 @@ box_process_register(struct ev_io *io, struct 
xrow_header *header)
  {
      assert(header->type == IPROTO_REGISTER);

-    struct tt_uuid instance_uuid = uuid_nil;
+    struct tt_uuid instance_uuid;
      struct vclock replica_vclock;
      xrow_decode_register_xc(header, &instance_uuid, &replica_vclock, 
NULL);

@@ -2740,8 +2740,8 @@ box_process_join(struct ev_io *io, struct 
xrow_header *header)
      assert(header->type == IPROTO_JOIN);

      /* Decode JOIN request */
-    struct tt_uuid instance_uuid = uuid_nil;
-    uint32_t replica_version_id = 0;
+    struct tt_uuid instance_uuid;
+    uint32_t replica_version_id;
      xrow_decode_join_xc(header, &instance_uuid, &replica_version_id);

      /* Check that bootstrap has been finished */
@@ -2847,11 +2847,10 @@ box_process_subscribe(struct ev_io *io, struct 
xrow_header *header)
      if (!is_box_configured)
          tnt_raise(ClientError, ER_LOADING);

-    struct tt_uuid replica_uuid = uuid_nil;
-    struct tt_uuid peer_replicaset_uuid = uuid_nil;
+    struct tt_uuid replica_uuid;
+    struct tt_uuid peer_replicaset_uuid;
      struct vclock replica_clock;
      uint32_t replica_version_id;
-    vclock_create(&replica_clock);
      bool anon;
      uint32_t id_filter;
      xrow_decode_subscribe_xc(header, &peer_replicaset_uuid, &replica_uuid,
diff --git a/src/box/relay.cc b/src/box/relay.cc
index 2947468ba..f5852df7b 100644
--- a/src/box/relay.cc
+++ b/src/box/relay.cc
@@ -683,8 +683,6 @@ relay_reader_f(va_list ap)
              struct xrow_header xrow;
              coio_read_xrow_timeout_xc(&io, &ibuf, &xrow,
                      replication_disconnect_timeout());
-            /* vclock is followed while decoding, zeroing it. */
-            vclock_create(&relay->recv_vclock);
              xrow_decode_vclock_xc(&xrow, &relay->recv_vclock);
              /*
               * Replica send us last replicated transaction

-- 
Serge Petrenko


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 2/2] xrow: reset parameters of decode_subscribe() to default
  2021-09-06  8:06     ` Serge Petrenko via Tarantool-patches
@ 2021-09-07 21:46       ` Vladislav Shpilevoy via Tarantool-patches
  0 siblings, 0 replies; 8+ messages in thread
From: Vladislav Shpilevoy via Tarantool-patches @ 2021-09-07 21:46 UTC (permalink / raw)
  To: Serge Petrenko, gorcunov; +Cc: tarantool-patches

Hi! Good job on the fixes!

LGTM.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Tarantool-patches] [PATCH v2 0/2] replication: fix uninitialized replica_version_id access
  2021-09-02 13:21 [Tarantool-patches] [PATCH v2 0/2] replication: fix uninitialized replica_version_id access Serge Petrenko via Tarantool-patches
                   ` (2 preceding siblings ...)
  2021-09-02 17:34 ` [Tarantool-patches] [PATCH v2 0/2] replication: fix uninitialized replica_version_id access Cyrill Gorcunov via Tarantool-patches
@ 2021-09-09 10:18 ` Kirill Yukhin via Tarantool-patches
  3 siblings, 0 replies; 8+ messages in thread
From: Kirill Yukhin via Tarantool-patches @ 2021-09-09 10:18 UTC (permalink / raw)
  To: Serge Petrenko; +Cc: tarantool-patches, v.shpilevoy

Hello,

On 02 сен 16:21, Serge Petrenko via Tarantool-patches wrote:
> https://github.com/tarantool/tarantool/tree/sp/version-uninitialized-access
> 
> Changes in v2
>  - rework patch 2: instead of initializing version in process_subscribe(),
>    reset all parameters to default values in xrow_decode_subscribe().

I've checked your patch into 2.8 and master.

--
Regards, Kirill Yukhin

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-09-09 10:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-02 13:21 [Tarantool-patches] [PATCH v2 0/2] replication: fix uninitialized replica_version_id access Serge Petrenko via Tarantool-patches
2021-09-02 13:21 ` [Tarantool-patches] [PATCH v2 1/2] box: remove unused variable in process_register() Serge Petrenko via Tarantool-patches
2021-09-02 13:21 ` [Tarantool-patches] [PATCH v2 2/2] xrow: reset parameters of decode_subscribe() to default Serge Petrenko via Tarantool-patches
2021-09-02 21:47   ` Vladislav Shpilevoy via Tarantool-patches
2021-09-06  8:06     ` Serge Petrenko via Tarantool-patches
2021-09-07 21:46       ` Vladislav Shpilevoy via Tarantool-patches
2021-09-02 17:34 ` [Tarantool-patches] [PATCH v2 0/2] replication: fix uninitialized replica_version_id access Cyrill Gorcunov via Tarantool-patches
2021-09-09 10:18 ` Kirill Yukhin via Tarantool-patches

Tarantool development patches archive

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lists.tarantool.org/tarantool-patches/0 tarantool-patches/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 tarantool-patches tarantool-patches/ https://lists.tarantool.org/tarantool-patches \
		tarantool-patches@dev.tarantool.org.
	public-inbox-index tarantool-patches

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git