lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230103152558.wtpgxdbsc6tql3gx@blixen>
Date:   Tue, 3 Jan 2023 16:26:40 +0100
From:   Pankaj Raghav <p.raghav@...sung.com>
To:     Sergei Shtepa <sergei.shtepa@...am.com>
CC:     <axboe@...nel.dk>, <corbet@....net>, <linux-block@...r.kernel.org>,
        <linux-doc@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <p.raghav@...sung.com>
Subject: Re: [PATCH v2 06/21] block, blksnap: module management interface
 functions

On Fri, Dec 09, 2022 at 03:23:16PM +0100, Sergei Shtepa wrote:
> +static int ioctl_tracker_mark_dirty_blocks(unsigned long arg)
> +{
> +	int ret = 0;
> +	struct blk_snap_tracker_mark_dirty_blocks karg;
> +	struct blk_snap_block_range *dirty_blocks_array;
> +
> +	if (copy_from_user(&karg, (void *)arg, sizeof(karg))) {
> +		pr_err("Unable to mark dirty blocks: invalid user buffer\n");
> +		return -ENODATA;
> +	}
> +
> +	dirty_blocks_array = kcalloc(
> +		karg.count, sizeof(struct blk_snap_block_range), GFP_KERNEL);
> +	if (!dirty_blocks_array)
> +		return -ENOMEM;
> +
> +	if (copy_from_user(dirty_blocks_array, (void *)karg.dirty_blocks_array,
> +			   karg.count * sizeof(struct blk_snap_block_range))) {
> +		pr_err("Unable to mark dirty blocks: invalid user buffer\n");
> +		ret = -ENODATA;

Minor nit:
The following could be done to keep it consistent with other functions:

	if (copy_from_user(dirty_blocks_array, (void *)karg.dirty_blocks_array,
			   karg.count * sizeof(struct blk_snap_block_range))) {
		pr_err("Unable to mark dirty blocks: invalid user buffer\n");
		ret = -ENODATA;
		goto out;
	}

	if (karg.dev_id.mj == snapimage_major())
		ret = snapshot_mark_dirty_blocks(
			MKDEV(karg.dev_id.mj, karg.dev_id.mn),
			dirty_blocks_array, karg.count);
	else
		ret = tracker_mark_dirty_blocks(
			MKDEV(karg.dev_id.mj, karg.dev_id.mn),
			dirty_blocks_array, karg.count);
out:
	kfree(dirty_blocks_array);

	return ret;
}


> +	} else {
> +		if (karg.dev_id.mj == snapimage_major())
> +			ret = snapshot_mark_dirty_blocks(
> +				MKDEV(karg.dev_id.mj, karg.dev_id.mn),
> +				dirty_blocks_array, karg.count);
> +		else
> +			ret = tracker_mark_dirty_blocks(
> +				MKDEV(karg.dev_id.mj, karg.dev_id.mn),
> +				dirty_blocks_array, karg.count);
> +	}
> +
> +	kfree(dirty_blocks_array);
> +
> +	return ret;
> +}
> +
-- 
Pankaj Raghav

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ