From: Dan Carpenter <dan.carpenter@oracle.com>
To: jbacik@redhat.com
Cc: linux-btrfs@vger.kernel.org
Subject: re: Btrfs: add support for multiple csum algorithms
Date: Fri, 15 Jun 2012 22:49:22 +0300 [thread overview]
Message-ID: <20120615194922.GA2278@elgon.mountain> (raw)
Hello Josef Bacik,
The patch 607d432da054: "Btrfs: add support for multiple csum
algorithms" from Dec 2, 2008, leads to the following warning:
fs/btrfs/disk-io.c:298 csum_tree_block()
error: memcpy() '&found' too small (4 vs 9)
fs/btrfs/disk-io.c
284 if (csum_size > sizeof(inline_result)) {
285 result = kzalloc(csum_size * sizeof(char), GFP_NOFS);
286 if (!result)
287 return 1;
288 } else {
289 result = (char *)&inline_result;
290 }
291
292 btrfs_csum_final(crc, result);
293
294 if (verify) {
295 if (memcmp_extent_buffer(buf, result, 0, csum_size)) {
296 u32 val;
297 u32 found = 0;
298 memcpy(&found, result, csum_size);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Before that commit we used to memcpy() 4 bytes and it was fine, but now
csum_size can be larger than 4 bytes and there is a potential for
memory corruption.
299
300 read_extent_buffer(buf, &val, 0, csum_size);
^^^^
Smatch complains that "val" is too small as well.
301 printk_ratelimited(KERN_INFO "btrfs: %s checksum verify "
302 "failed on %llu wanted %X found %X "
303 "level %d\n",
304 root->fs_info->sb->s_id,
305 (unsigned long long)buf->start, val, found,
306 btrfs_header_level(buf));
307 if (result != (char *)&inline_result)
308 kfree(result);
309 return 1;
regards,
dan carpenter
next reply other threads:[~2012-06-15 19:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-15 19:49 Dan Carpenter [this message]
2012-12-11 20:31 ` Btrfs: add support for multiple csum algorithms Dan Carpenter
-- strict thread matches above, loose matches on Subject: below --
2016-01-25 10:31 Dan Carpenter
2016-01-26 21:22 ` Liu Bo
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=20120615194922.GA2278@elgon.mountain \
--to=dan.carpenter@oracle.com \
--cc=jbacik@redhat.com \
--cc=linux-btrfs@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.