diff options
| author | Mikulas Patocka <mpatocka@redhat.com> | 2026-09-30 21:41:11 +0200 |
|---|---|---|
| committer | Mikulas Patocka <mpatocka@redhat.com> | 2026-10-01 13:07:17 +0200 |
| commit | b15dc73f60ebf02410bc7014ce34fb7fd1040045 (patch) | |
| tree | 377abff900281aecbc418291f49c7d510b02baa6 /drivers/md | |
| parent | c1ab80af0d99a906b60b769f2e692c37d2db1323 (diff) | |
dm-writecache: fix a crash if we attempt to use non-dax device
If we specify a non-DAX device as a cache device in the 'P' mode,
dm-writecache crashes on NULL pointer dereference inside dax_synchronous.
Note that this is not a security bug because only root can trigger it.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Fixes: a46624580376 ("dm writecache: reject asynchronous pmem devices")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-5
Diffstat (limited to 'drivers/md')
| -rw-r--r-- | drivers/md/dm-writecache.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index e974204b0d6f..2b3950dd45e8 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -2499,6 +2499,11 @@ invalid_optional: } if (WC_MODE_PMEM(wc)) { + if (!wc->ssd_dev->dax_dev) { + r = -EOPNOTSUPP; + ti->error = "Cache device is not a DAX device"; + goto bad; + } if (!dax_synchronous(wc->ssd_dev->dax_dev)) { r = -EOPNOTSUPP; ti->error = "Asynchronous persistent memory not supported as pmem cache"; |
