From: "Darrick J. Wong" <djwong@kernel.org>
To: sandeen@sandeen.net, djwong@kernel.org
Cc: Chandan Babu R <chandanrlinux@gmail.com>,
Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>,
linux-xfs@vger.kernel.org, chandanrlinux@gmail.com,
Chaitanya.Kulkarni@wdc.com
Subject: [PATCH 1/6] misc: fix valgrind complaints
Date: Mon, 08 Feb 2021 20:11:21 -0800 [thread overview]
Message-ID: <161284388183.3058224.7213452888406393105.stgit@magnolia> (raw)
In-Reply-To: <161284387610.3058224.6236053293202575597.stgit@magnolia>
From: Darrick J. Wong <djwong@kernel.org>
Zero the memory that we pass to the kernel via ioctls so that we never
pass userspace heap/stack garbage around. This silences valgrind
complaints about uninitialized padding areas.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
libhandle/handle.c | 10 ++++++----
scrub/inodes.c | 2 +-
scrub/spacemap.c | 3 +--
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/libhandle/handle.c b/libhandle/handle.c
index 5c1686b3..27abc6b2 100644
--- a/libhandle/handle.c
+++ b/libhandle/handle.c
@@ -235,8 +235,10 @@ obj_to_handle(
{
char hbuf [MAXHANSIZ];
int ret;
- uint32_t handlen;
- xfs_fsop_handlereq_t hreq;
+ uint32_t handlen = 0;
+ struct xfs_fsop_handlereq hreq = { };
+
+ memset(hbuf, 0, MAXHANSIZ);
if (opcode == XFS_IOC_FD_TO_HANDLE) {
hreq.fd = obj.fd;
@@ -275,7 +277,7 @@ open_by_fshandle(
{
int fsfd;
char *path;
- xfs_fsop_handlereq_t hreq;
+ struct xfs_fsop_handlereq hreq = { };
if ((fsfd = handle_to_fsfd(fshanp, &path)) < 0)
return -1;
@@ -382,7 +384,7 @@ attr_list_by_handle(
{
int error, fd;
char *path;
- xfs_fsop_attrlist_handlereq_t alhreq;
+ struct xfs_fsop_attrlist_handlereq alhreq = { };
if ((fd = handle_to_fsfd(hanp, &path)) < 0)
return -1;
diff --git a/scrub/inodes.c b/scrub/inodes.c
index bdc12df3..63865113 100644
--- a/scrub/inodes.c
+++ b/scrub/inodes.c
@@ -111,7 +111,7 @@ scan_ag_inodes(
xfs_agnumber_t agno,
void *arg)
{
- struct xfs_handle handle;
+ struct xfs_handle handle = { };
char descr[DESCR_BUFSZ];
struct xfs_inumbers_req *ireq;
struct xfs_bulkstat_req *breq;
diff --git a/scrub/spacemap.c b/scrub/spacemap.c
index 9653916d..a5508d56 100644
--- a/scrub/spacemap.c
+++ b/scrub/spacemap.c
@@ -47,11 +47,10 @@ scrub_iterate_fsmap(
int i;
int error;
- head = malloc(fsmap_sizeof(FSMAP_NR));
+ head = calloc(1, fsmap_sizeof(FSMAP_NR));
if (!head)
return errno;
- memset(head, 0, sizeof(*head));
memcpy(head->fmh_keys, keys, sizeof(struct fsmap) * 2);
head->fmh_count = FSMAP_NR;
next prev parent reply other threads:[~2021-02-09 4:17 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-09 4:11 [PATCHSET v4 0/6] various: random fixes Darrick J. Wong
2021-02-09 4:11 ` Darrick J. Wong [this message]
2021-02-09 9:19 ` [PATCH 1/6] misc: fix valgrind complaints Christoph Hellwig
2021-02-09 4:11 ` [PATCH 2/6] xfs_scrub: detect infinite loops when scanning inodes Darrick J. Wong
2021-02-09 9:26 ` Christoph Hellwig
2021-02-09 4:11 ` [PATCH 3/6] xfs_scrub: load and unload libicu properly Darrick J. Wong
2021-02-09 9:28 ` Christoph Hellwig
2021-02-09 4:11 ` [PATCH 4/6] xfs_scrub: handle concurrent directory updates during name scan Darrick J. Wong
2021-02-09 9:30 ` Christoph Hellwig
2021-02-09 16:53 ` Darrick J. Wong
2021-02-09 4:11 ` [PATCH 5/6] xfs_repair: check dquot id and type Darrick J. Wong
2021-02-09 9:31 ` Christoph Hellwig
2021-02-09 16:55 ` Darrick J. Wong
2021-02-10 9:48 ` Chandan Babu R
2021-02-11 17:06 ` [PATCH v4.1 " Darrick J. Wong
2021-02-12 12:08 ` Chandan Babu R
2021-02-09 4:11 ` [PATCH 6/6] xfs_scrub: fix weirdness in directory name check code Darrick J. Wong
2021-02-09 9:31 ` Christoph Hellwig
2021-02-10 10:04 ` Chandan Babu R
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=161284388183.3058224.7213452888406393105.stgit@magnolia \
--to=djwong@kernel.org \
--cc=chaitanya.kulkarni@wdc.com \
--cc=chandanrlinux@gmail.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@sandeen.net \
/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;
as well as URLs for NNTP newsgroup(s).