From: Jacob Pan <jacob.jun.pan@linux.intel.com>
To: Neil Horman <nhorman@tuxdriver.com>
Cc: linux-kernel@vger.kernel.org, Zhang Rui <rui.zhang@intel.com>
Subject: Re: [PATCH 1/2] tmon: Check log file for common secuirty issues
Date: Tue, 17 Jun 2014 14:13:02 -0700 [thread overview]
Message-ID: <20140617141302.7f5b0434@ultegra> (raw)
In-Reply-To: <1403035509-31815-2-git-send-email-nhorman@tuxdriver.com>
On Tue, 17 Jun 2014 16:05:08 -0400
Neil Horman <nhorman@tuxdriver.com> wrote:
> The tmon logging system blindly opens its log file on a static path,
> making it very easy for someone to redirect that log information to
> inappropriate places or overwrite other users data. Do some easy
> checking to make sure we're not logging to a symlink or a file owned
> by another user.
>
Acked-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> CC: Zhang Rui <rui.zhang@intel.com>
> CC: Jacob Pan <jacob.jun.pan@linux.intel.com>
> ---
> tools/thermal/tmon/tmon.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/tools/thermal/tmon/tmon.c b/tools/thermal/tmon/tmon.c
> index b30f531..059e0be 100644
> --- a/tools/thermal/tmon/tmon.c
> +++ b/tools/thermal/tmon/tmon.c
> @@ -142,6 +142,7 @@ static void start_syslog(void)
> static void prepare_logging(void)
> {
> int i;
> + struct stat logstat;
>
> if (!logging)
> return;
> @@ -152,6 +153,29 @@ static void prepare_logging(void)
> return;
> }
>
> + if (lstat(TMON_LOG_FILE, &logstat) < 0) {
> + syslog(LOG_ERR, "Unable to stat log file %s\n",
> TMON_LOG_FILE);
> + fclose(tmon_log);
> + tmon_log = NULL;
> + return;
> + }
> +
> + /* The log file must be a regular file owned by us */
> + if (S_ISLNK(logstat.st_mode)) {
> + syslog(LOG_ERR, "Log file is a symlink. Will not
> log\n");
> + fclose(tmon_log);
> + tmon_log = NULL;
> + return;
> + }
> +
> + if (logstat.st_uid != getuid()) {
> + syslog(LOG_ERR, "We don't own the log file. Not
> logging\n");
> + fclose(tmon_log);
> + tmon_log = NULL;
> + return;
> + }
> +
> +
> fprintf(tmon_log, "#----------- THERMAL SYSTEM CONFIG
> -------------\n"); for (i = 0; i < ptdata.nr_tz_sensor; i++) {
> char binding_str[33]; /* size of long + 1 */
[Jacob Pan]
--
Thanks,
Jacob
next prev parent reply other threads:[~2014-06-17 21:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-17 20:05 PATCH 0/2 tmon: fix a few minor security issues Neil Horman
2014-06-17 20:05 ` [PATCH 1/2] tmon: Check log file for common secuirty issues Neil Horman
2014-06-17 21:13 ` Jacob Pan [this message]
2014-06-17 20:05 ` [PATCH 2/2] tmon: set umask to a reasonable value Neil Horman
2014-06-17 21:14 ` Jacob Pan
2014-06-17 21:15 ` PATCH 0/2 tmon: fix a few minor security issues Jacob Pan
2014-07-01 11:42 ` Neil Horman
2014-07-01 13:49 ` Zhang Rui
2014-07-01 15:02 ` Neil Horman
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=20140617141302.7f5b0434@ultegra \
--to=jacob.jun.pan@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
--cc=rui.zhang@intel.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