After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 775685 - gcr: Fix failure case in gcr_secure_memory_try_realloc()
gcr: Fix failure case in gcr_secure_memory_try_realloc()
Status: RESOLVED FIXED
Product: gcr
Classification: Core
Component: General
unspecified
Other All
: Normal normal
: ---
Assigned To: GNOME keyring maintainer(s)
GNOME keyring maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2016-12-06 07:53 UTC by Philip Withnall
Modified: 2019-02-22 11:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gcr: Fix failure case in gcr_secure_memory_try_realloc() (4.04 KB, patch)
2016-12-06 07:53 UTC, Philip Withnall
none Details | Review
gck: Remove an unnecessary (transfer) annotation (970 bytes, patch)
2016-12-06 07:53 UTC, Philip Withnall
none Details | Review
tests: Add missing const qualifier (795 bytes, patch)
2016-12-06 07:53 UTC, Philip Withnall
none Details | Review

Description Philip Withnall 2016-12-06 07:53:33 UTC
One important patch, and two tiny little compiler warning fixes. The important patch fixes the behaviour of gcr_secure_memory_try_*() to actually return NULL when allocation fails (for example, due to hitting RLIMIT_MEMLOCK), rather than hitting an assertion failure. Since RLIMIT_MEMLOCK can often be surprisingly low (for example, 64KiB), this can be hit fairly easily in an application which is trying to use secure memory for more than just key storage.
Comment 1 Philip Withnall 2016-12-06 07:53:37 UTC
Created attachment 341449 [details] [review]
gcr: Fix failure case in gcr_secure_memory_try_realloc()

try_realloc() is explicitly documented as returning NULL in the failure
case, so remove an assertion that it can never happen. Similarly for
try_alloc().

This case can be hit if an application tries to allocate more than the
process’ RLIMIT_MEMLOCK limit (and the process is not privileged). This
limit is typically 64KiB, so not astronomical.

Add a test case.
Comment 2 Philip Withnall 2016-12-06 07:53:41 UTC
Created attachment 341450 [details] [review]
gck: Remove an unnecessary (transfer) annotation

GTypes cannot be owned or unowned, so a (transfer) annotation makes no
sense. g-ir-scanner was warning about it.
Comment 3 Philip Withnall 2016-12-06 07:53:46 UTC
Created attachment 341451 [details] [review]
tests: Add missing const qualifier

This fixes a compiler warning.
Comment 4 Stef Walter 2017-01-12 12:13:38 UTC
Thanks! Merged into gcr git master.

Attachment 341449 [details] pushed as 9d66118 - gcr: Fix failure case in gcr_secure_memory_try_realloc()
Attachment 341450 [details] pushed as 1ed6e17 - gck: Remove an unnecessary (transfer) annotation
Attachment 341451 [details] pushed as d3935af - tests: Add missing const qualifier