All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: Anand Jain <anand.jain@oracle.com>,
	Josef Bacik <josef@toxicpanda.com>,
	linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH v4 6/6] btrfs: use btrfs_get_dev_args_from_path in dev removal ioctls
Date: Wed, 6 Oct 2021 12:05:58 +0300	[thread overview]
Message-ID: <338ca6f9-9728-edc9-642c-7893573b1678@suse.com> (raw)
In-Reply-To: <e81e4690-377d-40f1-8488-21530ee6c57d@oracle.com>



On 6.10.21 г. 11:54, Anand Jain wrote:
<snip>

>> Suggested-by: Anand Jain <anand.jain@oracle.com>
>> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
>> ---
>>   fs/btrfs/ioctl.c   | 67 +++++++++++++++++++++++++++-------------------
>>   fs/btrfs/volumes.c | 15 +++++------
>>   fs/btrfs/volumes.h |  2 +-
>>   3 files changed, 48 insertions(+), 36 deletions(-)
>>
>> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
>> index b8508af4e539..c9d3f375df83 100644
>> --- a/fs/btrfs/ioctl.c
>> +++ b/fs/btrfs/ioctl.c
>> @@ -3160,6 +3160,7 @@ static long btrfs_ioctl_add_dev(struct
>> btrfs_fs_info *fs_info, void __user *arg)
>>     static long btrfs_ioctl_rm_dev_v2(struct file *file, void __user
>> *arg)
>>   {
>> +    BTRFS_DEV_LOOKUP_ARGS(args);
>>       struct inode *inode = file_inode(file);
>>       struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
>>       struct btrfs_ioctl_vol_args_v2 *vol_args;
>> @@ -3171,35 +3172,39 @@ static long btrfs_ioctl_rm_dev_v2(struct file
>> *file, void __user *arg)
>>       if (!capable(CAP_SYS_ADMIN))
>>           return -EPERM;
>>   -    ret = mnt_want_write_file(file);
>> -    if (ret)
>> -        return ret;
>> -
>>       vol_args = memdup_user(arg, sizeof(*vol_args));
>>       if (IS_ERR(vol_args)) {
> 
>>           ret = PTR_ERR(vol_args);
>> -        goto err_drop;
>> +        goto out;
> 
>      return  PTR_ERR(vol_args);
> 
> is fine here.
> 
>>       }
>>         if (vol_args->flags & ~BTRFS_DEVICE_REMOVE_ARGS_MASK) {
>>           ret = -EOPNOTSUPP;
>>           goto out;
> 
> At the label out, we call, btrfs_put_dev_args_from_path(&args).
> However, the args.fsid and args.uuid might not have initialized
> to NULL or a valid kmem address.

On tha contrary, the fact that args is initialized via a designated
initializer guarantees that the rest of the members of the struct are
going to be zero initialized, or more precisley as if they had a "static
lifetime"

https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html

<snip>

  reply	other threads:[~2021-10-06  9:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-05 20:12 [PATCH v4 0/6] Fix lockdep issues around device removal Josef Bacik
2021-10-05 20:12 ` [PATCH v4 1/6] btrfs: use num_device to check for the last surviving seed device Josef Bacik
2021-10-05 20:12 ` [PATCH v4 2/6] btrfs: add comments for device counts in struct btrfs_fs_devices Josef Bacik
2021-10-05 20:12 ` [PATCH v4 3/6] btrfs: do not call close_fs_devices in btrfs_rm_device Josef Bacik
2021-10-06  6:40   ` Nikolay Borisov
2021-10-13 17:47     ` David Sterba
2021-10-06  8:55   ` Anand Jain
2021-10-05 20:12 ` [PATCH v4 4/6] btrfs: handle device lookup with btrfs_dev_lookup_args Josef Bacik
2021-10-06  7:34   ` Nikolay Borisov
2021-10-13 18:23     ` David Sterba
2021-10-06  8:58   ` Anand Jain
2021-10-05 20:12 ` [PATCH v4 5/6] btrfs: add a btrfs_get_dev_args_from_path helper Josef Bacik
2021-10-06  8:24   ` Nikolay Borisov
2021-10-06  8:58   ` Anand Jain
2021-10-05 20:12 ` [PATCH v4 6/6] btrfs: use btrfs_get_dev_args_from_path in dev removal ioctls Josef Bacik
2021-10-06  8:54   ` Anand Jain
2021-10-06  9:05     ` Nikolay Borisov [this message]
2021-10-19  3:42       ` Anand Jain
2021-10-18 15:22 ` [PATCH v4 0/6] Fix lockdep issues around device removal 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=338ca6f9-9728-edc9-642c-7893573b1678@suse.com \
    --to=nborisov@suse.com \
    --cc=anand.jain@oracle.com \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.