Skip to content

Commit 3ff1ca0

Browse files
jhawthornmatzbot
authored andcommitted
[ruby/openssl] Add missing write barriers in X509
Both the X509 store and X509 store context were missing write barriers. To the callback object being stored in the ex data. These values were also being stored as an IV, however in Ruby HEAD we're now storing the IVs for T_DATA (generic IVs) on a separate object. So we need an additional write barrier. I believe this was always necessary, because we could have done incremental marking ahead of compaction, and without the write barrier the mark function could have been run before @verify_callback was assigned. This was detected by wbcheck ruby/openssl@1fda3a99ef
1 parent 6fe4ed5 commit 3ff1ca0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ext/openssl/ossl_x509store.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ ossl_x509store_set_vfy_cb(VALUE self, VALUE cb)
191191

192192
GetX509Store(self, store);
193193
rb_iv_set(self, "@verify_callback", cb);
194-
// We don't need to trigger a write barrier because `rb_iv_set` did it.
195194
X509_STORE_set_ex_data(store, store_ex_verify_cb_idx, (void *)cb);
195+
RB_OBJ_WRITTEN(self, Qundef, cb);
196196

197197
return cb;
198198
}
@@ -611,6 +611,7 @@ ossl_x509stctx_verify(VALUE self)
611611
GetX509StCtx(self, ctx);
612612
VALUE cb = rb_iv_get(self, "@verify_callback");
613613
X509_STORE_CTX_set_ex_data(ctx, stctx_ex_verify_cb_idx, (void *)cb);
614+
RB_OBJ_WRITTEN(self, Qundef, cb);
614615

615616
switch (X509_verify_cert(ctx)) {
616617
case 1:

0 commit comments

Comments
 (0)