Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 661730 Details for
Bug 883429
Incorrect synchronization in mmap cache
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
USe a macro to do memcpy with barriers
0001-Add-a-macro-to-copy-with-barriers.patch (text/plain), 3.94 KB, created by
Simo Sorce
on 2012-12-11 22:35:22 UTC
(
hide
)
Description:
USe a macro to do memcpy with barriers
Filename:
MIME Type:
Creator:
Simo Sorce
Created:
2012-12-11 22:35:22 UTC
Size:
3.94 KB
patch
obsolete
>From b01f7a88d066b707b485c79a6f5c9f09bc833ec5 Mon Sep 17 00:00:00 2001 >From: Simo Sorce <simo@redhat.com> >Date: Tue, 11 Dec 2012 17:23:19 -0500 >Subject: [PATCH] Add a macro to copy with barriers > >We have 2 places where we memcpy memory and need barriers protection. >Use a macro so we can consolidate code in one place. >--- > src/sss_client/nss_mc_common.c | 47 +++++++++++++++++++++++++++--------------- > 1 file changed, 30 insertions(+), 17 deletions(-) > >diff --git a/src/sss_client/nss_mc_common.c b/src/sss_client/nss_mc_common.c >index a361f57b9794cad0cded6c3bbad5f66543edb31b..7862dd0185cbde9f88deb869826f5ef645b02dcf 100644 >--- a/src/sss_client/nss_mc_common.c >+++ b/src/sss_client/nss_mc_common.c >@@ -38,18 +38,33 @@ > /* FIXME: handle name upper/lower casing ? Maybe a flag passed down by > * sssd or a flag in sss_mc_header ? per domain ? */ > >+#define MEMCPY_WITH_BARRIERS(res, dest, src, len) \ >+do { \ >+ uint32_t _b1; \ >+ res = false; \ >+ _b1 = (src)->b1; \ >+ if (MC_VALID_BARRIER(_b1)) { \ >+ __sync_synchronize(); \ >+ memcpy(dest, src, len); \ >+ __sync_synchronize(); \ >+ if ((dest)->b2 == _b1) { \ >+ res = true; \ >+ } \ >+ } \ >+} while(0) >+ > errno_t sss_nss_check_header(struct sss_cli_mc_ctx *ctx) > { > struct sss_mc_header h; >+ bool copy_ok; > int count; > > /* retry barrier protected reading max 5 times then give up */ > for (count = 5; count > 0; count--) { >- memcpy(&h, ctx->mmap_base, sizeof(struct sss_mc_header)); >- /* we need a barrier here to make sure the compiler does not optimize >- * too much and avoids updating the register for the next check */ >- __sync_synchronize(); >- if (MC_VALID_BARRIER(h.b1) && h.b1 == h.b2) { >+ MEMCPY_WITH_BARRIERS(copy_ok, &h, >+ (struct sss_mc_header *)ctx->mmap_base, >+ sizeof(struct sss_mc_header)); >+ if (copy_ok) { > /* record is consistent so we can proceed */ > break; > } >@@ -181,11 +196,12 @@ errno_t sss_nss_mc_get_record(struct sss_cli_mc_ctx *ctx, > uint32_t slot, struct sss_mc_rec **_rec) > { > struct sss_mc_rec *rec; >- void *rec_buf = NULL; >+ struct sss_mc_rec *copy_rec = NULL; > size_t buf_size = 0; > size_t rec_len; > uint32_t b1; > uint32_t b2; >+ bool copy_ok; > int count; > int ret; > >@@ -198,16 +214,16 @@ errno_t sss_nss_mc_get_record(struct sss_cli_mc_ctx *ctx, > __sync_synchronize(); > rec_len = rec->len; > __sync_synchronize(); >- b2 = rec->b1; >+ b2 = rec->b2; > if (!MC_VALID_BARRIER(b1) || b1 != b2) { > /* record is inconsistent, retry */ > continue; > } > > if (rec_len > buf_size) { >- free(rec_buf); >- rec_buf = malloc(rec_len); >- if (!rec_buf) { >+ free(copy_rec); >+ copy_rec = malloc(rec_len); >+ if (!copy_rec) { > ret = ENOMEM; > goto done; > } >@@ -215,13 +231,10 @@ errno_t sss_nss_mc_get_record(struct sss_cli_mc_ctx *ctx, > } > /* we cannot access data directly, we must copy data and then > * access the copy */ >- memcpy(rec_buf, rec, rec_len); >- rec = (struct sss_mc_rec *)rec_buf; >+ MEMCPY_WITH_BARRIERS(copy_ok, copy_rec, rec, rec_len); > > /* we must check data is consistent again after the copy */ >- if (MC_VALID_BARRIER(rec->b1) && >- rec->b1 == rec->b2 && >- rec->len == rec_len) { >+ if (copy_ok && b1 == copy_rec->b2) { > /* record is consistent, use it */ > break; > } >@@ -232,12 +245,12 @@ errno_t sss_nss_mc_get_record(struct sss_cli_mc_ctx *ctx, > goto done; > } > >- *_rec = rec; >+ *_rec = copy_rec; > ret = 0; > > done: > if (ret) { >- free(rec_buf); >+ free(copy_rec); > *_rec = NULL; > } > return ret; >-- >1.7.11.7 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 883429
:
660930
|
661730
|
662504