public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Muchun Song <songmuchun@bytedance.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	duanxiongchun@bytedance.com, smuchun@gmail.com,
	Luis Chamberlain <mcgrof@kernel.org>,
	Kees Cook <keescook@chromium.org>,
	Iurii Zaikin <yzaikin@google.com>
Subject: Re: [PATCH] sysctl: handle table->maxlen properly for proc_dobool
Date: Thu, 19 May 2022 14:09:01 +0100	[thread overview]
Message-ID: <YoZBbcEHcLqsAssF@casper.infradead.org> (raw)
In-Reply-To: <20220519125505.92400-1-songmuchun@bytedance.com>

On Thu, May 19, 2022 at 08:55:05PM +0800, Muchun Song wrote:
> @@ -428,6 +428,8 @@ static int do_proc_dobool_conv(bool *negp, unsigned long *lvalp,
>  				int write, void *data)
>  {
>  	if (write) {
> +		if (*negp || (*lvalp != 0 && *lvalp != 1))
> +			return -EINVAL;
>  		*(bool *)valp = *lvalp;
>  	} else {
>  		int val = *(bool *)valp;

Is this the right approach?  Or should we do as C does and interpret
writing non-zero as true?  ie:

		*(bool *)valp = (bool)*lvalp;

(is that cast needed?  It wouldn't be if it were an int, but bool is a
bit weird)


  reply	other threads:[~2022-05-19 13:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-19 12:55 [PATCH] sysctl: handle table->maxlen properly for proc_dobool Muchun Song
2022-05-19 13:09 ` Matthew Wilcox [this message]
2022-05-19 14:10   ` Muchun Song

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=YoZBbcEHcLqsAssF@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=duanxiongchun@bytedance.com \
    --cc=keescook@chromium.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=smuchun@gmail.com \
    --cc=songmuchun@bytedance.com \
    --cc=yzaikin@google.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