# CVE-2021-47635: ubifs: Fix to add refcount once page is set private

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** HIGH 7.8
- **CVSS:** 7.8 (v3.1, CNA) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: High; Integrity impact: High; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.31% (percentile 16, 2026-11-26)
- **Published:** 2025-02-26T01:54:09.701Z
- **Modified:** 2026-08-05T08:48:41.669Z

## Who should check

- Anyone running Linux \>= 1e51764a3c2ac05a23a22b2a95ddee4d9bffb16d, \< c34ae24a2590fee96a3a7735ba2fa6cc52306221; \>= 1e51764a3c2ac05a23a22b2a95ddee4d9bffb16d, \< 4f75bab98565afd4f905059c56ec4caba88a7eec; \>= 1e51764a3c2ac05a23a22b2a95ddee4d9bffb16d, \< 5aaa2c0f0052b02c4a982993d4c5bb68fb7cbe22; \>= 1e51764a3c2ac05a23a22b2a95ddee4d9bffb16d, \< fbeb2139eed65e929ce806c6468e6601ade01b1b; \>= 1e51764a3c2ac05a23a22b2a95ddee4d9bffb16d, \< 3b67db8a6ca83e6ff90b756d3da0c966f61cd37b
- Anyone running Linux 2.6.27

## Description

In the Linux kernel, the following vulnerability has been resolved:

ubifs: Fix to add refcount once page is set private

MM defined the rule \[1\] very clearly that once page was set with PG\_private
flag, we should increment the refcount in that page, also main flows like
pageout(), migrate\_page() will assume there is one additional page
reference count if page\_has\_private() returns true. Otherwise, we may
get a BUG in page migration:

  page:0000000080d05b9d refcount:-1 mapcount:0 mapping:000000005f4d82a8
  index:0xe2 pfn:0x14c12
  aops:ubifs\_file\_address\_operations \[ubifs\] ino:8f1 dentry name:"f30e"
  flags: 0x1fffff80002405(locked\|uptodate\|owner\_priv\_1\|private\|node=0\|
  zone=1\|lastcpupid=0x1fffff)
  page dumped because: VM\_BUG\_ON\_PAGE(page\_count(page) != 0)
  ------------\[ cut here \]------------
  kernel BUG at include/linux/page\_ref.h:184!
  invalid opcode: 0000 \[\#1\] SMP
  CPU: 3 PID: 38 Comm: kcompactd0 Not tainted 5.15.0-rc5
  RIP: 0010:migrate\_page\_move\_mapping+0xac3/0xe70
  Call Trace:
    ubifs\_migrate\_page+0x22/0xc0 \[ubifs\]
    move\_to\_new\_page+0xb4/0x600
    migrate\_pages+0x1523/0x1cc0
    compact\_zone+0x8c5/0x14b0
    kcompactd+0x2bc/0x560
    kthread+0x18c/0x1e0
    ret\_from\_fork+0x1f/0x30

Before the time, we should make clean a concept, what does refcount means
in page gotten from grab\_cache\_page\_write\_begin(). There are 2 situations:
Situation 1: refcount is 3, page is created by \_\_page\_cache\_alloc.
  TYPE\_A - the write process is using this page
  TYPE\_B - page is assigned to one certain mapping by calling
	   \_\_add\_to\_page\_cache\_locked()
  TYPE\_C - page is added into pagevec list corresponding current cpu by
	   calling lru\_cache\_add()
Situation 2: refcount is 2, page is gotten from the mapping's tree
  TYPE\_B - page has been assigned to one certain mapping
  TYPE\_A - the write process is using this page (by calling
	   page\_cache\_get\_speculative())
Filesystem releases one refcount by calling put\_page() in xxx\_write\_end(),
the released refcount corresponds to TYPE\_A (write task is using it). If
there are any processes using a page, page migration process will skip the
page by judging whether expected\_page\_refs() equals to page refcount.

The BUG is caused by following process:
    PA(cpu 0)                           kcompactd(cpu 1)
				compact\_zone
ubifs\_write\_begin
  page\_a = grab\_cache\_page\_write\_begin
    add\_to\_page\_cache\_lru
      lru\_cache\_add
        pagevec\_add // put page into cpu 0's pagevec
  (refcnf = 3, for page creation process)
ubifs\_write\_end
  SetPagePrivate(page\_a) // doesn't increase page count !
  unlock\_page(page\_a)
  put\_page(page\_a)  // refcnt = 2
				\[...\]

    PB(cpu 0)
filemap\_read
  filemap\_get\_pages
    add\_to\_page\_cache\_lru
      lru\_cache\_add
        \_\_pagevec\_lru\_add // traverse all pages in cpu 0's pagevec
	  \_\_pagevec\_lru\_add\_fn
	    SetPageLRU(page\_a)
				isolate\_migratepages
                                  isolate\_migratepages\_block
				    get\_page\_unless\_zero(page\_a)
				    // refcnt = 3
                                      list\_add(page\_a, from\_list)
				migrate\_pages(from\_list)
				  \_\_unmap\_and\_move
				    move\_to\_new\_page
				      ubifs\_migrate\_page(page\_a)
				        migrate\_page\_move\_mapping
					  expected\_page\_refs get 3
                                  (migration\[1\] + mapping\[1\] + private\[1\])
	 release\_pages
	   put\_page\_testzero(page\_a) // refcnt = 3
                                          page\_ref\_freeze  // refcnt = 0
	     page\_ref\_dec\_and\_test(0 - 1 = -1)
                                          page\_ref\_unfreeze
                                            VM\_BUG\_ON\_PAGE(-1 != 0, page)

UBIFS doesn't increase the page refcount after setting private flag, which
leads to page migration task believes the page is not used by any other
processes, so the page is migrated. This causes concurrent accessing on
page refcount between put\_page() called by other process(eg. read process
calls lru\_cache\_add) and page\_ref\_unfreeze() called by mi
---truncated---

## Affected and fixed versions

- Linux: \>= 1e51764a3c2ac05a23a22b2a95ddee4d9bffb16d, \< c34ae24a2590fee96a3a7735ba2fa6cc52306221; \>= 1e51764a3c2ac05a23a22b2a95ddee4d9bffb16d, \< 4f75bab98565afd4f905059c56ec4caba88a7eec; \>= 1e51764a3c2ac05a23a22b2a95ddee4d9bffb16d, \< 5aaa2c0f0052b02c4a982993d4c5bb68fb7cbe22; \>= 1e51764a3c2ac05a23a22b2a95ddee4d9bffb16d, \< fbeb2139eed65e929ce806c6468e6601ade01b1b; \>= 1e51764a3c2ac05a23a22b2a95ddee4d9bffb16d, \< 3b67db8a6ca83e6ff90b756d3da0c966f61cd37b (cvelist)
- Linux: 2.6.27 (cvelist)

## Mitigation

- Upgrade Linux to 3b67db8a6ca83e6ff90b756d3da0c966f61cd37b or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2021-47635. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2021-47635.md
Affected: Linux >= 1e51764a3c2ac05a23a22b2a95ddee4d9bffb16d, < c34ae24a2590fee96a3a7735ba2fa6cc52306221; >= 1e51764a3c2ac05a23a22b2a95ddee4d9bffb16d, < 4f75bab98565afd4f905059c56ec4caba88a7eec; >= 1e51764a3c2ac05a23a22b2a95ddee4d9bffb16d, < 5aaa2c0f0052b02c4a982993d4c5bb68fb7cbe22; >= 1e51764a3c2ac05a23a22b2…
Fixed in: Linux 4f75bab98565afd4f905059c56ec4caba88a7eec, Linux 5aaa2c0f0052b02c4a982993d4c5bb68fb7cbe22, Linux 3b67db8a6ca83e6ff90b756d3da0c966f61cd37b

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2021-47635 being exploited?

There is no confirmed exploitation: CVE-2021-47635 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.31% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2021-47635?

High: CVSS 7.8 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2021-47635?

Linux \>= 1e51764a3c2ac05a23a22b2a95ddee4d9bffb16d, \< c34ae24a2590fee96a3a7735ba2fa6cc52306221; \>= 1e51764a3c2ac05a23a22b2a95ddee4d9bffb16d, \< 4f75bab98565afd4f905059c56ec4caba88a7eec; \>= 1e51764a3c2ac05a23a22b2a95ddee4d9bffb16d, \< 5aaa2c0f0052b02c4a982993d4c5bb68fb7cbe22; \>= 1e51764a3c2ac05a23a22b2a95ddee4d9bffb16d, \< fbeb2139eed65e929ce806c6468e6601ade01b1b; \>= 1e51764a3c2ac05a23a22b2a95ddee4d9bffb16d, \< 3b67db8a6ca83e6ff90b756d3da0c966f61cd37b; Linux 2.6.27.

### Is there a fix for CVE-2021-47635?

Yes. Fixed in Linux 4f75bab98565afd4f905059c56ec4caba88a7eec, Linux 5aaa2c0f0052b02c4a982993d4c5bb68fb7cbe22, Linux 3b67db8a6ca83e6ff90b756d3da0c966f61cd37b. Upgrade Linux to 3b67db8a6ca83e6ff90b756d3da0c966f61cd37b or later.

### How do I check if I'm affected by CVE-2021-47635?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- patch: <https://git.kernel.org/stable/c/c34ae24a2590fee96a3a7735ba2fa6cc52306221>
- patch: <https://git.kernel.org/stable/c/4f75bab98565afd4f905059c56ec4caba88a7eec>
- patch: <https://git.kernel.org/stable/c/5aaa2c0f0052b02c4a982993d4c5bb68fb7cbe22>
- patch: <https://git.kernel.org/stable/c/fbeb2139eed65e929ce806c6468e6601ade01b1b>
- patch: <https://git.kernel.org/stable/c/3b67db8a6ca83e6ff90b756d3da0c966f61cd37b>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2021-47635>

HTML: <https://flawdb.com/CVE-2021-47635> · JSON: <https://flawdb.com/api/v1/entries/CVE-2021-47635>
