Re: [PATCH net-next] ethtool: tsconfig: reject zero-valued tx_type and rx_filter bitsets
Joe Damato <[email protected]>
| Newsgroups | org.kernel.vger.netdev |
|---|---|
| Message-ID | <any9dja3ZPSIJ/[email protected]> |
On Wed, Aug 12, 2026 at 09:22:30AM -0700, Jakub Kicinski wrote: > The ffs()/fls() guard in ethnl_set_tsconfig() was meant to enforce > that the user selects exactly one tx_type (and one rx_filter) > at a time (off / none are explicit types with non-zero values). > However, both ffs(0) and fls(0) return 0, so the guard passes > a zero-valued bitset through. > > The subsequent ffs(req_tx_type) - 1 would produce -1, if user selected > no bit. net_hwtstamp_validate() catches the invalid -1 downstream, > but returns a generic error (-ERANGE) without telling the user > what went wrong. Return -EINVAL + extack instead. > > Replace the ffs()/fls() comparison with a hweight32() == 1 check. > > Signed-off-by: Jakub Kicinski <[email protected]> > --- > CC: [email protected] > CC: [email protected] > --- > net/ethtool/tsconfig.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) Reviewed-by: Joe Damato <[email protected]>