public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org, Edward Adam Davis <eadavis@qq.com>
Subject: Re: [PATCH 0/3] Ioctl buffer name/path validation
Date: Wed, 14 Feb 2024 13:22:32 -0800	[thread overview]
Message-ID: <20240214212232.GA480208@zen.localdomain> (raw)
In-Reply-To: <cover.1707935035.git.dsterba@suse.com>

On Wed, Feb 14, 2024 at 07:31:54PM +0100, David Sterba wrote:
> This is inspired by a report and fix [1] where device replace buffers
> were not properly validated (third patch). The other two are doing
> proper validation of vol args path or name so that an unterminated
> string is reported as an error rather than relying on later actions like
> open that would catch an invalid path.
> 
> (I'm OK to replace the third patch in favor of Edward as he spent time
> analyzing it but we did not agree on a fix and I did not get a reply
> with the suggestion I implemented in the end.)
> 
> [1] https://lore.kernel.org/linux-btrfs/tencent_44CA0665C9836EF9EEC80CB9E7E206DF5206@qq.com/

LGTM. One note/question: would it be helpful to pull out:

```
if (memchr(str, 0, str) == NULL)
        return -ENAMETOOLONG;
return 0;
```

into a helper and use it in all these places?

Either way,
Reviewed-by: Boris Burkov <boris@bur.io>

> 
> David Sterba (3):
>   btrfs: factor out validation of btrfs_ioctl_vol_args::name
>   btrfs: factor out validation of btrfs_ioctl_vol_args_v2::name
>   btrfs: dev-replace: properly validate device names
> 
>  fs/btrfs/dev-replace.c | 24 +++++++++++++++----
>  fs/btrfs/fs.h          |  2 ++
>  fs/btrfs/ioctl.c       | 54 +++++++++++++++++++++++++++++++++++-------
>  fs/btrfs/super.c       |  5 +++-
>  4 files changed, 72 insertions(+), 13 deletions(-)
> 
> -- 
> 2.42.1
> 

  parent reply	other threads:[~2024-02-14 21:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14 18:31 [PATCH 0/3] Ioctl buffer name/path validation David Sterba
2024-02-14 18:31 ` [PATCH 1/3] btrfs: factor out validation of btrfs_ioctl_vol_args::name David Sterba
2024-02-14 18:32 ` [PATCH 2/3] btrfs: factor out validation of btrfs_ioctl_vol_args_v2::name David Sterba
2024-02-14 18:32 ` [PATCH 3/3] btrfs: dev-replace: properly validate device names David Sterba
2024-02-14 21:22 ` Boris Burkov [this message]
2024-02-15 15:13   ` [PATCH 0/3] Ioctl buffer name/path validation David Sterba

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=20240214212232.GA480208@zen.localdomain \
    --to=boris@bur.io \
    --cc=dsterba@suse.com \
    --cc=eadavis@qq.com \
    --cc=linux-btrfs@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