Search Linux Wireless

Re: [PATCH] netlink: add policy attribute range validation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Another thing to note:

Given the union of validation_data pointer and min/max, we'll always get
into this:

> +	/* validate range */
> +	if (pt->min || pt->max) {

if validation_data is set, but of course end up taking the default case,
where nothing further happens:

> +		default:
> +			/* no further validation */
> +			validate = false;
> +			break;
> +		}
> +
> +		if (validate && (value < pt->min || value > pt->max)) {
> +			NL_SET_ERR_MSG_ATTR(extack, nla,
> +					    "integer out of range");
> +			return -ERANGE;
> +		}
> +	}
> +
>  	return 0;

I'm not *entirely* happy with this, but I haven't been able to come up
with a way that doesn't do this, doesn't duplicate the nla types list
(NLA_{U,S}{8,16,32,64}) in the code, and also loads the attribute value
only if validation is needed.

johannes



[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux