Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1714794

Summary: numa_police_memory(3) semantics changed in RHEL8
Product: Red Hat Enterprise Linux 8 Reporter: Joe Korty <joe.korty>
Component: numactlAssignee: Pingfan Liu <piliu>
Status: CLOSED ERRATA QA Contact: Robin Hack <rhack>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.2CC: ashankar, codonell, dj, fweimer, mnewsome, pfrankli, piliu, rhack, ruyang
Target Milestone: rcKeywords: TestCaseNotNeeded, Triaged
Target Release: 8.0Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: numactl-2.0.12-13.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1949860 (view as bug list) Environment:
Last Closed: 2021-11-09 19:41:02 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1674330, 1949860    

Description Joe Korty 2019-05-28 20:59:23 UTC
Description of problem:
In RHEL8, numa_police_memory(3) required both read and write access to the pages it is to fault in.  Prior to RHEL8 (include RHEL8-Beta), only read access was required.

The bug manifests itself as a SIGSEGV violation.

Version-Release number of selected component (if applicable):


How reproducible:
Every time.


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:
Here is the function definition, extracted from -lnuma via gdb, on RHEL-7.5, which requires only read access, and RHEL-8, which requires both read and write access.  Please go back to the 7.5 version.


7.5 version (-lnuma):

847	void numa_police_memory(void *mem, size_t size)
848	{
849		int pagesize = numa_pagesize_int();
850		unsigned long i; 
851		for (i = 0; i < size; i += pagesize)
852			asm volatile("" :: "r" (((volatile unsigned char *)mem)[i]));
853	}

8.0 version (-lnuma):

58	void numa_police_memory(void *mem, size_t size)
859	{
860		int pagesize = numa_pagesize_int();
861		unsigned long i;
862		for (i = 0; i < size; i += pagesize)
863			((volatile char*)mem)[i] = ((volatile char*)mem)[i];
864	}

Comment 1 Joe Korty 2019-05-28 21:02:58 UTC
I might add that the RHEL8 version is unsafe as it modifies the shared memory area which might interleave with other store operations, performed by other processes or threads, at the same time as numa_police_memory is executing.

Comment 2 Florian Weimer 2019-05-28 21:28:23 UTC
I believe libnuma comes from numactl.

Comment 3 Pingfan Liu 2019-07-29 07:24:15 UTC
This is introduced by:
commit aeff67cc502b192a267f53259a355d9d2696178e
Author: Krzysztof Kulakowski <krzysztof.kulakowski>
Date:   Thu May 25 10:10:29 2017 -0400

    Fix for numa_police_memory()
    
    Implementation of this function was based on outdated assumption
    that memory read causes page fault (and allocation of physical memory).
    
    This assumption is not true for Linux since 2.6.32 (a13ea5b); Uninitialized
    memory is backed by zero_page until time of first write.
    
    This patch makes numa_policy_memory() works as expected, by rewriting
    (instead of just reading) first byte of every page.

Comment 4 Florian Weimer 2019-07-29 08:39:39 UTC
(In reply to Joe Korty from comment #1)
> I might add that the RHEL8 version is unsafe as it modifies the shared
> memory area which might interleave with other store operations, performed by
> other processes or threads, at the same time as numa_police_memory is
> executing.

Yes, this is looks really, really problematic.  Is there a system call that could be used to get the desired effect in a safe manner?

Comment 8 Pingfan Liu 2021-03-10 02:39:09 UTC
open an issue on https://github.com/numactl/numactl/issues/105

Comment 10 Pingfan Liu 2021-04-19 02:10:35 UTC
Hi Robin,

I see you take the QA ownership of 8.3. WOuld you mind to take it for this bug in 8.5?

Thanks,
Pingfan

Comment 19 errata-xmlrpc 2021-11-09 19:41:02 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (numactl bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:4406