Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2347118ybv; Fri, 14 Feb 2020 16:56:14 -0800 (PST) X-Google-Smtp-Source: APXvYqzC54eIyLLs7gq6Yz4fmHzSFxqNeB5wTyT5507OSwwK6c6qN0Nnz4amlDuTwiYWOdtUmdPc X-Received: by 2002:a9d:116:: with SMTP id 22mr4122261otu.149.1581728174596; Fri, 14 Feb 2020 16:56:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581728174; cv=none; d=google.com; s=arc-20160816; b=mDH9JDgnY9bY8ZhBa9sAtjPKEE5GhjGWYsBhgBc5m3DtNk3tWvbJuGToWteGYVznMh GDhdbq/wuhl1wR+3HmWjNvRA5Ca4tm5z7pY71WbJSmO7wEugAegi7/6u8HNCJBlQPrkK BQ5xDgyq0PHOFKH0ypVRcqTJDC0M1Y+wh82IgvXvmuQVAOOtfgzNfUVxGFoJi4w4Mre8 VCiGq4I+veIz94QF9xi1jcy4Ok76iW/JNapLkfEyffA4jY1nBqQH2l+GamhFaZBUwnmN XDzsfpfKDa4Ctv8nDg2G6IGSDVjjfiQml/Uej7WmMqD/kO10IcRwPgu8WfQ2eIYXp+Ia rvHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:cc:to:subject:from; bh=NcDE9yl9obVVjTgfWVKHZMXtCZRyllqgDei8TuGsbNI=; b=zqWdsBdrjSkXuIT2pxAEibocrJmKhHEegZ2d6MVpUihf2lS4dbqFTCQfEz6zRf9X1P Q6ioJz76xoeuVpxR6mx3AjMgWz5Nmkap3o7A0Uoc/sgtzsRG6D8FojO34Qq5DytCkrmg KA+0mm9XGOMnA5q8bn8xUtANGN+QcuJ7EFYkxY5zDnuoO+VulAying0ml5MAnsXZllpj dyWnqwRCJRetVResXm4XQRcvqmzf6HOANTZ1jft46e7JygN21sblGtQ/oZnV0oWrha8m bFTdh1z3M7ysMo4LVoGPXNpIC1TvJfwFHWIEL3ic1Yb/Dlu8qzqWCf+h3Z09OT/2/qCX dSvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a12si3307506oie.87.2020.02.14.16.56.00; Fri, 14 Feb 2020 16:56:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727682AbgBOAzz (ORCPT + 99 others); Fri, 14 Feb 2020 19:55:55 -0500 Received: from mx2.suse.de ([195.135.220.15]:54098 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725924AbgBOAzz (ORCPT ); Fri, 14 Feb 2020 19:55:55 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1B636AC7C; Sat, 15 Feb 2020 00:55:53 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id 4D202E03D6; Sat, 15 Feb 2020 01:55:53 +0100 (CET) From: Michal Kubecek Subject: [PATCH net] ethtool: fix application of verbose no_mask bitset To: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Message-Id: <20200215005553.4D202E03D6@unicorn.suse.cz> Date: Sat, 15 Feb 2020 01:55:53 +0100 (CET) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A bitset without mask in a _SET request means we want exactly the bits in the bitset to be set. This works correctly for compact format but when verbose format is parsed, ethnl_update_bitset32_verbose() only sets the bits present in the request bitset but does not clear the rest. This can cause incorrect results like lion:~ # ethtool eth0 | grep Wake Supports Wake-on: pumbg Wake-on: g lion:~ # ethtool -s eth0 wol u lion:~ # ethtool eth0 | grep Wake Supports Wake-on: pumbg Wake-on: ug when the second ethtool command issues request ETHTOOL_MSG_WOL_SET ETHTOOL_A_WOL_HEADER ETHTOOL_A_HEADER_DEV_NAME = "eth0" ETHTOOL_A_WOL_MODES ETHTOOL_A_BITSET_NOMASK ETHTOOL_A_BITSET_BITS ETHTOOL_A_BITSET_BITS_BIT ETHTOOL_BITSET_BIT_INDEX = 1 Fix the logic by clearing the whole target bitmap before we start iterating through the request bits. Fixes: 10b518d4e6dd ("ethtool: netlink bitset handling") Signed-off-by: Michal Kubecek --- net/ethtool/bitset.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ethtool/bitset.c b/net/ethtool/bitset.c index fce45dac4205..8977fe1f3946 100644 --- a/net/ethtool/bitset.c +++ b/net/ethtool/bitset.c @@ -447,7 +447,10 @@ ethnl_update_bitset32_verbose(u32 *bitmap, unsigned int nbits, "mask only allowed in compact bitset"); return -EINVAL; } + no_mask = tb[ETHTOOL_A_BITSET_NOMASK]; + if (no_mask) + ethnl_bitmap32_clear(bitmap, 0, nbits, mod); nla_for_each_nested(bit_attr, tb[ETHTOOL_A_BITSET_BITS], rem) { bool old_val, new_val; -- 2.25.0