Files
msm-5.15/include/linux/page_pinner.h
Suren Baghdasaryan 23fb3111f6 ANDROID: page_pinner: prevent pp_buffer access before initialization
If page_pinner is configured with page_pinner_enabled=false and
failure_tracking=true, pp_buffer will be accessed without being
initialized. Prevent this by adding page_pinner_inited checks in
functions that access it.

Fixes: 898cfbf094 ("ANDROID: mm: introduce page_pinner")
Bug: 259024332
Bug: 260179017
Change-Id: I8f612cae3e74d36e8a4eee5edec25281246cbe5e
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2022-11-27 10:30:33 -08:00

55 lines
1.3 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __LINUX_PAGE_PINNER_H
#define __LINUX_PAGE_PINNER_H
#include <linux/jump_label.h>
#ifdef CONFIG_PAGE_PINNER
extern struct static_key_false page_pinner_inited;
extern struct static_key_true failure_tracking;
extern struct page_ext_operations page_pinner_ops;
extern void __free_page_pinner(struct page *page, unsigned int order);
void __page_pinner_failure_detect(struct page *page);
void __page_pinner_put_page(struct page *page);
static inline void free_page_pinner(struct page *page, unsigned int order)
{
if (static_branch_unlikely(&page_pinner_inited))
__free_page_pinner(page, order);
}
static inline void page_pinner_put_page(struct page *page)
{
if (!static_branch_unlikely(&page_pinner_inited))
return;
if (!static_branch_unlikely(&failure_tracking))
return;
__page_pinner_put_page(page);
}
static inline void page_pinner_failure_detect(struct page *page)
{
if (!static_branch_unlikely(&page_pinner_inited))
return;
if (!static_branch_unlikely(&failure_tracking))
return;
__page_pinner_failure_detect(page);
}
#else
static inline void free_page_pinner(struct page *page, unsigned int order)
{
}
static inline void page_pinner_put_page(struct page *page)
{
}
static inline void page_pinner_failure_detect(struct page *page)
{
}
#endif /* CONFIG_PAGE_PINNER */
#endif /* __LINUX_PAGE_PINNER_H */