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]
Date: Fri, 2 Feb 2024 09:17:13 +0800
From: Yu Kuai <yukuai1@...weicloud.com>
To: linan666@...weicloud.com, song@...nel.org, neilb@...e.com,
 mariusz.tkaczyk@...ux.intel.com, shli@...com
Cc: linux-raid@...r.kernel.org, linux-kernel@...r.kernel.org,
 yi.zhang@...wei.com, houtao1@...wei.com, yangerkun@...wei.com,
 "yukuai (C)" <yukuai3@...wei.com>
Subject: Re: [PATCH v5 1/8] md: merge the check of capabilities into
 md_ioctl_valid()

在 2024/02/01 14:33, linan666@...weicloud.com 写道:
> From: Li Nan <linan122@...wei.com>
> 
> There is no functional change. Just to make code cleaner.
> 
> Signed-off-by: Li Nan <linan122@...wei.com>

LGTM
Reviewed-by: Yu Kuai <yukuai3@...wei.com>

> ---
>   drivers/md/md.c | 30 ++++++++++++------------------
>   1 file changed, 12 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index e351e6c51cc7..1b509fb82040 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -7545,16 +7545,17 @@ static int md_getgeo(struct block_device *bdev, struct hd_geometry *geo)
>   	return 0;
>   }
>   
> -static inline bool md_ioctl_valid(unsigned int cmd)
> +static inline int md_ioctl_valid(unsigned int cmd)
>   {
>   	switch (cmd) {
> -	case ADD_NEW_DISK:
>   	case GET_ARRAY_INFO:
> -	case GET_BITMAP_FILE:
>   	case GET_DISK_INFO:
> +	case RAID_VERSION:
> +		return 0;
> +	case ADD_NEW_DISK:
> +	case GET_BITMAP_FILE:
>   	case HOT_ADD_DISK:
>   	case HOT_REMOVE_DISK:
> -	case RAID_VERSION:
>   	case RESTART_ARRAY_RW:
>   	case RUN_ARRAY:
>   	case SET_ARRAY_INFO:
> @@ -7563,9 +7564,11 @@ static inline bool md_ioctl_valid(unsigned int cmd)
>   	case STOP_ARRAY:
>   	case STOP_ARRAY_RO:
>   	case CLUSTERED_DISK_NACK:
> -		return true;
> +		if (!capable(CAP_SYS_ADMIN))
> +			return -EACCES;
> +		return 0;
>   	default:
> -		return false;
> +		return -ENOTTY;
>   	}
>   }
>   
> @@ -7625,18 +7628,9 @@ static int md_ioctl(struct block_device *bdev, blk_mode_t mode,
>   	struct mddev *mddev = NULL;
>   	bool did_set_md_closing = false;
>   
> -	if (!md_ioctl_valid(cmd))
> -		return -ENOTTY;
> -
> -	switch (cmd) {
> -	case RAID_VERSION:
> -	case GET_ARRAY_INFO:
> -	case GET_DISK_INFO:
> -		break;
> -	default:
> -		if (!capable(CAP_SYS_ADMIN))
> -			return -EACCES;
> -	}
> +	err = md_ioctl_valid(cmd);
> +	if (err)
> +		return err;
>   
>   	/*
>   	 * Commands dealing with the RAID driver but not any
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ