linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Nilsson <daniel@dnil.se>
To: viro@zeniv.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Daniel Nilsson <daniel@dnil.se>
Subject: [PATCH] VFS: Prevent core dump with core_pattern set to empty string
Date: Wed, 24 Jul 2013 23:30:50 +0200	[thread overview]
Message-ID: <1374701450-88005-1-git-send-email-daniel@dnil.se> (raw)

If the core_pattern (proc/sys/core_pattern) is set to an empty string
a core dump is still made but to a file with a filename set by an
uninitialized buffer in format_corename(). This patch fixes the use of the
uninitialized buffer and also aborts the core dump with a warning message
when core_pattern is set to an empty string.

Tested and developed against 3.11-rc2

Signed-off-by: Daniel Nilsson <daniel@dnil.se>
---
 fs/coredump.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/fs/coredump.c b/fs/coredump.c
index 72f816d..5035402 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -170,6 +170,11 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
 	if (ispipe)
 		++pat_ptr;
 
+	if (*pat_ptr == '\0') {
+		err = cn_printf(cn, "");
+		goto out;
+	}
+
 	/* Repeat as long as we have more pattern to process and more output
 	   space */
 	while (*pat_ptr) {
@@ -617,6 +622,13 @@ void do_coredump(siginfo_t *siginfo)
 			goto fail_unlock;
 		}
 
+		if (cn.corename[0] == '\0') {
+			printk(KERN_WARNING
+			       "core_pattern contains an empty string!\n");
+			printk(KERN_WARNING "Skipping core dump\n");
+			goto fail_unlock;
+		}
+
 		cprm.file = filp_open(cn.corename,
 				 O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag,
 				 0600);
-- 
1.7.9.5


                 reply	other threads:[~2013-07-24 21:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1374701450-88005-1-git-send-email-daniel@dnil.se \
    --to=daniel@dnil.se \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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).