From patchwork Fri Mar 26 20:22:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 410524 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFA63C433E0 for ; Fri, 26 Mar 2021 20:23:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9B11F619DC for ; Fri, 26 Mar 2021 20:23:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230114AbhCZUXC (ORCPT ); Fri, 26 Mar 2021 16:23:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:41212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230134AbhCZUW2 (ORCPT ); Fri, 26 Mar 2021 16:22:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 32C0161A02; Fri, 26 Mar 2021 20:22:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616790148; bh=ddnL4s7v9wNRvgNJHmRcz23Wtlt0n1J4XmQZLmnpSQk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hvYDKBNU001fcZ6NlR2FFTlvQzQ/Tp9qlULbX5BhidZYvLG9JoxryZlYKN8EoTLcA Xx4EAjN8ihiEzTv5Gz6e+dAVK4icgGdU5Mv9UiJ/Fbz+N1D9Sx2J5Ib7DUx2t0Id+H ZC6w0+1LK4FhET5/1VXMcqdUlSWipWtiFoh86CzJpl/H43y4KHK1cfl5ouWyo00FrQ RiTIxDrLydB4bXPWEp/raTg0CAvUywU5NfBQMlKuLPOdVl6ViAAGmuqxZFHfbf0HA5 P+x5ifTR8V/XVyrL0zBADCUFsbPmr9lt7eDXNLB5QyqY6GgDLU7wWkPEvLoeo15ctK xmTlM66fOljmg== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, andrew@lunn.ch, mkubecek@suse.cz, Jakub Kicinski Subject: [PATCH net-next 1/3] ethtool: fec: add note about reuse of reserved Date: Fri, 26 Mar 2021 13:22:21 -0700 Message-Id: <20210326202223.302085-2-kuba@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210326202223.302085-1-kuba@kernel.org> References: <20210326202223.302085-1-kuba@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org struct ethtool_fecparam::reserved can't be used in SET, because ethtool user space doesn't zero-initialize the structure. Make this clear. Suggested-by: Andrew Lunn Signed-off-by: Jakub Kicinski --- include/uapi/linux/ethtool.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index f6ef7d42c7a1..9a47c3efd8ca 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -1382,6 +1382,10 @@ struct ethtool_per_queue_op { * @fec: Bitmask of configured FEC modes. * @reserved: Reserved for future extensions, ignore on GET, write 0 for SET. * + * Note that @reserved was never validated on input and ethtool user space + * left it uninitialized when calling SET. Hence going forward it can only be + * used to return a value to userspace with GET. + * * FEC modes supported by the device can be read via %ETHTOOL_GLINKSETTINGS. * FEC settings are configured by link autonegotiation whenever it's enabled. * With autoneg on %ETHTOOL_GFECPARAM can be used to read the current mode. From patchwork Fri Mar 26 20:22:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 409949 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D85C7C433DB for ; Fri, 26 Mar 2021 20:23:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BDD3561A2A for ; Fri, 26 Mar 2021 20:23:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230195AbhCZUXE (ORCPT ); Fri, 26 Mar 2021 16:23:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:41236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229957AbhCZUW3 (ORCPT ); Fri, 26 Mar 2021 16:22:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A619D61A26; Fri, 26 Mar 2021 20:22:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616790148; bh=QHjnw3KqPF5iOeQnEXEE+suiSKyU0v8PKHJRx8TGUWE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=geekgQiMcZgXe0Q5pdvbrrSwzG+uBNNlqjgcrx8Aaw5Z9qUaB5amjzO1O5vQZFY+v 3ABepfnWO+7/Vf2dMchBgJA6rOEWDUGtJiH03SdI9sP/SGZwVoh1mL26dyHysQGsds ojhF15ddbwFlJOL3dY9tThS+jJFa0ZQ0pbH05QFKydgbIxhvk1xcgKl4pY0NnMKO/Z nT5yXICwyEUpRCGiBQPOGt0erBfwSrYWkpRb3A43k0AUxQOAo/rK6oorMCERqbNXKb 1so1hX5ptPUCi+910bKaPqcYRWPiIVE679zVXQtgiMWj+4VSfar2Nz3H8HKlTdAwSH MwVE0VKsr6Mjg== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, andrew@lunn.ch, mkubecek@suse.cz, Jakub Kicinski , kernel test robot , Dan Carpenter Subject: [PATCH net-next 2/3] ethtool: fec: fix FEC_NONE check Date: Fri, 26 Mar 2021 13:22:22 -0700 Message-Id: <20210326202223.302085-3-kuba@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210326202223.302085-1-kuba@kernel.org> References: <20210326202223.302085-1-kuba@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Dan points out we need to use the mask not the bit (which is 0). Reported-by: kernel test robot Reported-by: Dan Carpenter Fixes: 42ce127d9864 ("ethtool: fec: sanitize ethtool_fecparam->fec") Signed-off-by: Jakub Kicinski --- net/ethtool/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 8797533ddc4b..26b3e7086075 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -2586,7 +2586,7 @@ static int ethtool_set_fecparam(struct net_device *dev, void __user *useraddr) if (copy_from_user(&fecparam, useraddr, sizeof(fecparam))) return -EFAULT; - if (!fecparam.fec || fecparam.fec & ETHTOOL_FEC_NONE_BIT) + if (!fecparam.fec || fecparam.fec & ETHTOOL_FEC_NONE) return -EINVAL; fecparam.active_fec = 0; From patchwork Fri Mar 26 20:22:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 409950 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98986C433C1 for ; Fri, 26 Mar 2021 20:23:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 72C5D61A02 for ; Fri, 26 Mar 2021 20:23:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230176AbhCZUXD (ORCPT ); Fri, 26 Mar 2021 16:23:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:41246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230026AbhCZUW3 (ORCPT ); Fri, 26 Mar 2021 16:22:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 154FE61A28; Fri, 26 Mar 2021 20:22:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616790149; bh=5rbU0oSiI3DGCF4AZPTkQe3dq+R6HKdIjaMFOAkufWc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YTq/kNR1Vk2EwD771vQW9MIgfovVY7Xs15uEEzHvb8Z+TndcOw4RtoLWVxzD0q2eq ygqYsIGRHqL96zmSIR3+eABsK94/sAtinpkE5lp37VF1o/EAuOyHM3NsItnAtiNT5n tiZCpU/DIqS1/tNoM1OE9GPWl1ROhdeFu66JlNxVZWjM7COzOBrVzRglB+Z48B45af 7Y55dSY+B+CSQt5s2djzZ+XTt1rv413N3q5fx6fJCji6Hq08HlbHXVhm1NI4BRRAkV RXGn1OU9GM23DBPg1pZCIC+sO6Zo6QNwk0d+wg+QskwLkB9KD3h0gAsFnN4qWxSn4i EqLRY8qea0IEA== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, andrew@lunn.ch, mkubecek@suse.cz, Jakub Kicinski Subject: [PATCH net-next 3/3] ethtool: document the enum values not defines Date: Fri, 26 Mar 2021 13:22:23 -0700 Message-Id: <20210326202223.302085-4-kuba@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210326202223.302085-1-kuba@kernel.org> References: <20210326202223.302085-1-kuba@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org kdoc does not have good support for documenting defines, and we can't abuse the enum documentation because it generates warnings. Signed-off-by: Jakub Kicinski --- include/uapi/linux/ethtool.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index 9a47c3efd8ca..868b513d4f54 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -1414,16 +1414,16 @@ struct ethtool_fecparam { /** * enum ethtool_fec_config_bits - flags definition of ethtool_fec_configuration - * @ETHTOOL_FEC_NONE: FEC mode configuration is not supported. Should not - * be used together with other bits. GET only. - * @ETHTOOL_FEC_AUTO: Select default/best FEC mode automatically, usually based - * link mode and SFP parameters read from module's EEPROM. - * This bit does _not_ mean autonegotiation. - * @ETHTOOL_FEC_OFF: No FEC Mode - * @ETHTOOL_FEC_RS: Reed-Solomon FEC Mode - * @ETHTOOL_FEC_BASER: Base-R/Reed-Solomon FEC Mode - * @ETHTOOL_FEC_LLRS: Low Latency Reed Solomon FEC Mode (25G/50G Ethernet - * Consortium) + * @ETHTOOL_FEC_NONE_BIT: FEC mode configuration is not supported. Should not + * be used together with other bits. GET only. + * @ETHTOOL_FEC_AUTO_BIT: Select default/best FEC mode automatically, usually + * based link mode and SFP parameters read from module's + * EEPROM. This bit does _not_ mean autonegotiation. + * @ETHTOOL_FEC_OFF_BIT: No FEC Mode + * @ETHTOOL_FEC_RS_BIT: Reed-Solomon FEC Mode + * @ETHTOOL_FEC_BASER_BIT: Base-R/Reed-Solomon FEC Mode + * @ETHTOOL_FEC_LLRS_BIT: Low Latency Reed Solomon FEC Mode (25G/50G Ethernet + * Consortium) */ enum ethtool_fec_config_bits { ETHTOOL_FEC_NONE_BIT,