lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a07cdbce55668405e8bc9471834e9237@codeaurora.org>
Date:   Wed, 24 Feb 2021 20:21:44 +0530
From:   Sai Prakash Ranjan <saiprakash.ranjan@...eaurora.org>
To:     Doug Anderson <dianders@...omium.org>
Cc:     Mathieu Poirier <mathieu.poirier@...aro.org>,
        Suzuki K Poulose <suzuki.poulose@....com>,
        Mike Leach <mike.leach@...aro.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Leo Yan <leo.yan@...aro.org>, coresight@...ts.linaro.org,
        Stephen Boyd <swboyd@...omium.org>,
        Denis Nikitin <denik@...omium.org>,
        Mattias Nissler <mnissler@...omium.org>,
        Al Grant <al.grant@....com>,
        linux-arm-msm <linux-arm-msm@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Linux ARM <linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH 3/4] coresight: etm4x: Add support to exclude kernel mode
 tracing

Hi,

Thanks for taking a look, comments inline.

On 2021-02-23 01:44, Doug Anderson wrote:
> Hi,
> 
> On Fri, Jan 29, 2021 at 11:08 AM Sai Prakash Ranjan
> <saiprakash.ranjan@...eaurora.org> wrote:
>> 
>> @@ -1202,6 +1207,13 @@ void etm4_config_trace_mode(struct etmv4_config 
>> *config)
>>         /* excluding kernel AND user space doesn't make sense */
>>         WARN_ON_ONCE(mode == (ETM_MODE_EXCL_KERN | 
>> ETM_MODE_EXCL_USER));
>> 
>> +       if (!(mode & ETM_MODE_EXCL_KERN) && 
>> IS_ENABLED(CONFIG_EXCLUDE_KERNEL_HW_ITRACE)) {
>> +               dev_err(&drvdata->csdev->dev,
>> +                       "Kernel mode tracing is not allowed, check 
>> your kernel config\n");
>> +               config->mode |= ETM_MODE_EXCL_KERN;
>> +               return;
> 
> So I'm not an expert on this code, but the above looks suspicious to
> me.  Specifically you are still modifying "config->mode" even though
> printing an "error" (dev_err, not dev_warn) and then skipping the rest
> of this function.  Since you're skipping the rest of this function
> you're not applying the access, right?  Naively I'd have expected one
> of these:
> 
> 1. Maybe the "dev_err" should be a "dev_warn" and then you shouldn't
> "return".  In this case you're just implicitly adding
> "ETM_MODE_EXCL_KERN" (and shouting) but then making things work.  Of
> course, then what happens if the user already specified
> "ETM_MODE_EXCL_USER" too?  As per the comment above that "doesn't make
> sense".  ...so maybe the code wouldn't behave properly...
> 
> 2. Maybe you should be modifying this function to return an error code.
> 

mode_store() which is the caller of this function sets the config->mode
based on the value passed in the sysfs, so if the user passes the mode
which doesn't exclude the kernel even though the kernel config is 
enabled
and the code just sets it, then that is an error and the user should be
warned about, so I used dev_err, but I can change it to dev_warn if that
is preferred. And to make sysfs mode show the original mode after 
failure,
I set the mode in etm4_config_trace_mode().

But you are right, I am skipping to set the config for other mode bits
and returning which is wrong, will fix it as you suggest below.

> 3. Maybe you should just be updating the one caller of this function
> to error check this right at the beginning of the function and then
> fail the sysfs write if the user did the wrong thing.  Then in
> etm4_config_trace_mode you could just have a WARN_ON_ONCE if the
> kernel wasn't excluded...
> 

Right, will do this.

Thanks,
Sai

-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a 
member
of Code Aurora Forum, hosted by The Linux Foundation

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ