Re: [PATCH 1/2] ethtool: improve compat ioctl handling

From: Christoph Hellwig
Date: Sat Sep 19 2020 - 01:43:51 EST


> + if (ethtool_translate_compat()) {
> + struct compat_ethtool_rxnfc crxnfc = {};
> +
> + if (copy_from_user(&crxnfc, useraddr,
> + min(size, sizeof(crxnfc))))
> + return -EFAULT;
> +
> + *rxnfc = (struct ethtool_rxnfc) {
> + .cmd = crxnfc.cmd,
> + .flow_type = crxnfc.flow_type,
> + .data = crxnfc.data,
> + .fs = {
> + .flow_type = crxnfc.fs.flow_type,
> + .h_u = crxnfc.fs.h_u,
> + .h_ext = crxnfc.fs.h_ext,
> + .m_u = crxnfc.fs.m_u,
> + .m_ext = crxnfc.fs.m_ext,
> + .ring_cookie = crxnfc.fs.ring_cookie,
> + .location = crxnfc.fs.location,
> + },
> + .rule_cnt = crxnfc.rule_cnt,
> + };

I'd split the compat version into a self-contained noinline helper.
Same for ethtool_rxnfc_copy_to_user.

Otherwise this looks good:

Reviewed-by: Christoph Hellwig <hch@xxxxxx>