From: Aaron Tomlin <atomlin@atomlin.com>
To: steved@redhat.com, tbecker@redhat.com
Cc: yi.zhang@redhat.com, linux-nfs@vger.kernel.org
Subject: [PATCH 1/2] nfsrahead: zero-initialise device_info struct
Date: Mon, 9 Mar 2026 10:50:24 -0400 [thread overview]
Message-ID: <20260309145025.107623-2-atomlin@atomlin.com> (raw)
In-Reply-To: <20260309145025.107623-1-atomlin@atomlin.com>
A recent commit introduced a fast-path rejection mechanism to prevent
udev worker thread exhaustion. However, this optimisation exposed a bug
in the initialisation of the device_info struct in main().
When the fast-path is triggered (e.g., for a physical block device like
8:16), get_device_info() instantly returns -ENODEV. Because this early
exit occurs before get_mountinfo() is invoked, init_device_info() is
never called.
Consequently, the device_info struct remains populated with
uninitialised stack memory. When main() catches the error and jumps to
the cleanup path, free_device_info() attempts to call free() on garbage
pointers, resulting in a glibc abort(3).
Fix this by explicitly zero-initialising the device_info struct at
declaration, preventing the cleanup path from freeing uninitialised
memory during an early exit.
Fixes: 0f5fe65d ("nfsrahead: fix udev worker exhaustion by skipping non-NFS devices")
Reported-by: Yi Zhang <yi.zhang@redhat.com>
Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
---
tools/nfsrahead/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/nfsrahead/main.c b/tools/nfsrahead/main.c
index 78cd2581..33487f37 100644
--- a/tools/nfsrahead/main.c
+++ b/tools/nfsrahead/main.c
@@ -191,7 +191,7 @@ static int conf_get_readahead(const char *kind) {
int main(int argc, char **argv)
{
int ret = 0, opt;
- struct device_info device;
+ struct device_info device = { 0 };
unsigned int readahead = 128, log_level, log_stderr = 0;
--
2.51.0
next prev parent reply other threads:[~2026-03-09 14:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 14:50 [PATCH 0/2] nfsrahead: fix uninitialised memory crash and refine fast-path logging Aaron Tomlin
2026-03-09 14:50 ` Aaron Tomlin [this message]
2026-03-09 14:50 ` [PATCH 2/2] nfsrahead: quieten misleading error for non-NFS block devices Aaron Tomlin
2026-03-11 8:27 ` [PATCH 0/2] nfsrahead: fix uninitialised memory crash and refine fast-path logging Yi Zhang
2026-03-11 16:11 ` Steve Dickson
2026-03-11 19:45 ` Aaron Tomlin
2026-03-12 12:50 ` Steve Dickson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260309145025.107623-2-atomlin@atomlin.com \
--to=atomlin@atomlin.com \
--cc=linux-nfs@vger.kernel.org \
--cc=steved@redhat.com \
--cc=tbecker@redhat.com \
--cc=yi.zhang@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox