From: Benjamin Poirier <bpoirier@nvidia.com>
To: kexec@lists.infradead.org
Subject: [PATCH v2 makedumpfile 1/3] Fix off by one error when checking cache_size
Date: Thu, 8 Jul 2021 16:06:09 +0900 [thread overview]
Message-ID: <20210708070611.291260-2-bpoirier@nvidia.com> (raw)
In-Reply-To: <20210708070611.291260-1-bpoirier@nvidia.com>
Given the test in write_cache():
if (cd->buf_size < cd->cache_size)
return TRUE;
a write is done if buf_size == cache_size.
The test at the beginning of write_kdump_page() intends to detect cases
when write_cache() will do a write, however it was missing this boundary
condition. This would lead write_kdump_page() to ignore errors from
write_cache().
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
---
makedumpfile.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/makedumpfile.c b/makedumpfile.c
index fcb571f..aa05be7 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -7993,8 +7993,8 @@ write_kdump_page(struct cache_data *cd_header, struct cache_data *cd_page,
* write the buffer cd_header into dumpfile and then write the cd_page.
* With that, when enospc occurs, we can save more useful information.
*/
- if (cd_header->buf_size + sizeof(*pd) > cd_header->cache_size
- || cd_page->buf_size + pd->size > cd_page->cache_size){
+ if (cd_header->buf_size + sizeof(*pd) >= cd_header->cache_size ||
+ cd_page->buf_size + pd->size >= cd_page->cache_size) {
if( !write_cd_buf(cd_header) ) {
memset(cd_header->buf, 0, cd_header->cache_size);
write_cd_buf(cd_header);
--
2.32.0
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2021-07-08 7:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-08 7:06 [PATCH v2 makedumpfile 0/3] Add option to limit file size Benjamin Poirier
2021-07-08 7:06 ` Benjamin Poirier [this message]
2021-07-08 7:06 ` [PATCH v2 makedumpfile 2/3] Dump dmesg using write_and_check_space() Benjamin Poirier
2021-07-08 7:06 ` [PATCH v2 makedumpfile 3/3] Add -L option to limit output file size Benjamin Poirier
2021-07-30 2:13 ` [PATCH v2 makedumpfile 0/3] Add option to limit " HAGIO KAZUHITO(萩尾 一仁)
2021-07-30 3:51 ` Benjamin Poirier
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=20210708070611.291260-2-bpoirier@nvidia.com \
--to=bpoirier@nvidia.com \
--cc=kexec@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox