public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Heiko Carstens <hca@linux.ibm.com>
To: "GONG, Ruiqi" <gongruiqi@huaweicloud.com>
Cc: Kees Cook <keescook@chromium.org>, Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, gongruiqi1@huawei.com
Subject: Re: [PATCH] lkdtm: use the return value of strim()
Date: Fri, 18 Aug 2023 12:44:44 +0200	[thread overview]
Message-ID: <20230818104444.10148-A-hca@linux.ibm.com> (raw)
In-Reply-To: <953b0290-a703-2bd8-179b-01442f736768@huaweicloud.com>

On Fri, Aug 18, 2023 at 10:39:06AM +0800, GONG, Ruiqi wrote:
> 
> On 2023/08/18 0:55, Kees Cook wrote:
> > On Thu, Aug 17, 2023 at 10:21:17PM +0800, GONG, Ruiqi wrote:
> >> From: "GONG, Ruiqi" <gongruiqi1@huawei.com>
> >>
> >> Make use of the return value of strim() to achieve left-trim as well as
> >> right-trim, which prevents the following unusual fail case:
> >>
> >>  # echo " EXCEPTION" > /sys/kernel/debug/provoke-crash/DIRECT
> >>  sh: write error: Invalid argument
...
> >>  	/* NULL-terminate and remove enter */
> >>  	buf[count] = '\0';
> >> -	strim(buf);
> >> +	buf = strim(buf);
> >>  
> >>  	crashtype = find_crashtype(buf);
> >>  	free_page((unsigned long)buf);
> > 
> > Will free_page() still work in this case, though? The address won't
> > match the allocation any more...
> 
> Yes I noticed that, but I was under the impression that it's fine to do
> free_page(paddr + offset_in_page) since the offset is within the page,
> and its corresponding struct page can still be found when being freed.
> Please let me know if this thought is wrong and I will submit another
> version.

The question is rather why you think this patch makes any sense at
all. Nobody is doing what you described above - hence there is no
problem. The comments in the code even say strim() is used to remove the
trailing '\n'. If anybody passes a string with whitespace at the beginning
then that's just a user error.

There really is no point in patches like this.

  reply	other threads:[~2023-08-18 10:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-17 14:21 [PATCH] lkdtm: use the return value of strim() GONG, Ruiqi
2023-08-17 16:55 ` Kees Cook
2023-08-18  2:39   ` GONG, Ruiqi
2023-08-18 10:44     ` Heiko Carstens [this message]
2023-08-22 12:03 ` Greg Kroah-Hartman

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=20230818104444.10148-A-hca@linux.ibm.com \
    --to=hca@linux.ibm.com \
    --cc=arnd@arndb.de \
    --cc=gongruiqi1@huawei.com \
    --cc=gongruiqi@huaweicloud.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox