public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Namjae Jeon <linkinjeon@kernel.org>,
	Steve French <sfrench@samba.org>,
	Hyunchul Lee <hyc.lee@gmail.com>,
	linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] ksmbd: remove unnecessary conditions
Date: Tue, 7 Sep 2021 13:17:05 +0300	[thread overview]
Message-ID: <20210907101705.GH1935@kadam> (raw)
In-Reply-To: <YTc4ClL0EwuHsPXP@google.com>

On Tue, Sep 07, 2021 at 06:59:38PM +0900, Sergey Senozhatsky wrote:
> On (21/09/07 12:14), Dan Carpenter wrote:
> [..]
> > > > > 
> > > > > Can make_kuid() return INVALID_UID? IOW, uid_valid(uid) here as well?
> > > > 
> > > > No need to check twice.  We're going to check at the end.
> > > > 
> > > > > 
> > > > > > +
> > > > > > +		/* If this is an idmapped mount, apply the idmapping. */
> > > > > > +		uid = kuid_from_mnt(user_ns, uid);
> > > > > > +		if (uid_valid(uid)) {
> > > >                     ^^^^^^^^^^^^^^
> > > > The check here is sufficient.
> > > 
> > > My point was more that a potentially invalid UID is passed to kuid_from_mnt()
> > > and kgid_from_mnt(). I don't see map_id_up(), for example, checking that
> > > passed UID is valid. So decided to double check.
> > 
> > But you've seen it now, right?
> 
> A linear search in array of 5 elements or a binary search in array of 340
> elements? Yea, I saw it. I'd prefer one extra uid_valid(), if you'd ask
> me - why call the function if we already know that it'll fail.

It's a failure path.  Hopefully people will only give us valid data.

We would normally only optimize the failure path if we thought that it
could be used as a DoS vector.

regards,
dan carpenter

  reply	other threads:[~2021-09-07 10:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-07  7:34 [PATCH] ksmbd: remove unnecessary conditions Dan Carpenter
2021-09-07  8:06 ` Sergey Senozhatsky
2021-09-07  8:54   ` Dan Carpenter
2021-09-07  9:04     ` Sergey Senozhatsky
2021-09-07  9:14       ` Dan Carpenter
2021-09-07  9:59         ` Sergey Senozhatsky
2021-09-07 10:17           ` Dan Carpenter [this message]
2021-09-07 10:34             ` Sergey Senozhatsky

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=20210907101705.GH1935@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=hyc.lee@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=senozhatsky@chromium.org \
    --cc=sfrench@samba.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