Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp788444lqs; Fri, 14 Jun 2024 05:59:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX53Y6i3O6jWh12oLVOq7xVEFC7LNLs1wg9DIsOf2dH3ejelYkD2QWuqHhTlGWY+o9+vFW7R5e3W/hle5uMNoTa9SpGALL7RNDWQXxp0Q== X-Google-Smtp-Source: AGHT+IH2mrASL99huoSwvav2FCTJBSfYwmchfPZZyU4IJQ/90c4SGmHi/PMuK1HlM/JpFg5XVcDO X-Received: by 2002:a05:6902:701:b0:de5:9eb4:1ec1 with SMTP id 3f1490d57ef6-dff1549047cmr3169723276.48.1718369965444; Fri, 14 Jun 2024 05:59:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718369965; cv=pass; d=google.com; s=arc-20160816; b=Pwu9jIGYrbeZeaM1hmU8CarAUIOAhJi6QDBtKmSmaAVwSXFy0o87Ds2juRKuQ4a1E2 xrBDl3XZFoPuwUiV+rPaoCo/ZThnZp0t0J4ezDb8P6BUEDT2r2UZj2LgrNO7bJIF6pKC Zcd/3SbyEPHzId/cncpq0OCFvvUcf6L9DNW/Vca907VoKnBsarUe5oFLNa9vEixRNQ54 UUKqAKIjebl//yfRLC5YnbbP09gjDRjj6Z+yHLdKdJk4cy60AYgMxpfTrZu+4cf7H74Z sFEt0Je0cLkPzfUElTXh6gWD78ROkxU59SX3sTODDDCzDsnl8QpvXSapjrrVVEQvL5D9 6+cw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:message-id:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:date :from:dkim-signature; bh=tLrW3dFgIALwA7464td3OVv9LMPrFz4P6TZkrlk65Bo=; fh=jovUlPdrYLxAZzQvX3yupU7nTa/l9pmuX3rFidwfIck=; b=a0lSXJInKKHPxrOjwklSSumLXy0NK7ytK9YN6xpo0TrGr5hBvpgfL+CTDkf5rDMplm Nqt8zoW8DLkFjTmhEm7LqGywmz/HvH5G30T+DpVkQGqd295B1UbcoE4qGvaLPNtgm3je twY/rRsLLPMdvpF/LAGwFyT6rQwVj+4Kc4lKjY9wsHWgar5EhFBro+PIguCjLTRS5fkO UgE0z56aOno8ZPYr2He+7jUWCo9YzHg8oJkEAMpj8cbF+/cgjisKNiY4AmKym75T8nqG p9wMfGxij5S6acfiS/+AdlG0spz0HTzU98nREmKF1PxCbMtKciTDkyCBw5o97tQ1SyBq xXdw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PLYIQ+d5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-214922-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214922-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-44211342ec3si34150021cf.780.2024.06.14.05.59.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 05:59:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214922-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PLYIQ+d5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-214922-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214922-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 25DC31C22225 for ; Fri, 14 Jun 2024 12:59:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0540D19A2A8; Fri, 14 Jun 2024 12:59:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PLYIQ+d5" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A37D1990C2; Fri, 14 Jun 2024 12:59:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718369956; cv=none; b=HD673VR/47ul3uXUkZDh4R8FHYLv3RTG0aCJicB1U5OCOc8CzLPw+Hiz1XunB6Ch6Vv/ynVIU9zAChlFfNo66rVthqrmm+Y4eGMPZWiA1WA2BLr/aU+uOp5vHImzLaAmrgspv3db3KefWJyKJu73xXUG0E69oEMsFzeDKbGj8hs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718369956; c=relaxed/simple; bh=72YwQ/7+JDf4h/iYndf9k40v1XEkmlBBOisQcZ77H1A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=GeD26KlBVt37HWhbqx/KHJSUPgYQrP9rY9M8GicsDZUwr257lf0tjKPJ0nWNKN+NUsTyjstH2lhXXsbTpOnDQnA67VtO0jwbptw7uv0M9b0BzJVaLXTDi1GOfGTc+9KLruZDfvPB/J/RK/UhX5JLkeAGRePkTYYBsAJJkkMz4S4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PLYIQ+d5; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F39A1C2BD10; Fri, 14 Jun 2024 12:59:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718369955; bh=72YwQ/7+JDf4h/iYndf9k40v1XEkmlBBOisQcZ77H1A=; h=From:Date:Subject:To:Cc:From; b=PLYIQ+d5xIZ7PmFNaN1cYMs0XRZyn6wslfWglXTdxOBYanhqE9bVxqKot10ZQnE32 h4aBUoa6GFiUBWVe+hlWxhwP9bHduoLHu71HH0/FzlJbFSxJJUcM31/ZjddCxaGIjM thHFpSIQYRhq5Yos46dF7KPrgo96/HD8ydTnOu9MKoaLhyhJ6rh8Lf5cZXN7leWiHW HSR6PqNivCzOQCPbNJz4jpNCU6D26IZNbq25AeEoOF+YU24QtfrJhBWvK5oOtY/+Nt R8aZERgk2cef6lW1wSDC+uWahBpx/YAM6dVatZHTTZl83tNiftFOv0CFG8fQOo7lru r7fmRSlpnmDzw== From: Jeff Layton Date: Fri, 14 Jun 2024 08:59:10 -0400 Subject: [PATCH] nfsd: fix error handling bug in nfsd_nl_pool_mode_get_doit Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240614-nfsd-next-v1-1-d360eea79d0b@kernel.org> X-B4-Tracking: v=1; b=H4sIAJ0+bGYC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIxMDM0MT3by04hTdvNSKEt0U0zSzpKSUNAMj8xQloPqCotS0zAqwWdGxtbU ArPBQS1sAAAA= To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: Jakub Kicinski , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1657; i=jlayton@kernel.org; h=from:subject:message-id; bh=72YwQ/7+JDf4h/iYndf9k40v1XEkmlBBOisQcZ77H1A=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmbD6i98vkm1783UDy76Wu3K7VmDJyApKpxSjY/ VFk09Yks2KJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZmw+ogAKCRAADmhBGVaC FTL9EADBYcNMnm3fO12t6XrT67eLIM59SZBrffA7Wwr2D4JfJPfVMAK37Mf7HtIQlBUXwsnzRQP 0Zzeb1ZU1f5jiQsmCLv1Mahse9wk/p1MgLArGyn5bgp2U+YGcrAgyIFVzsX31Bu12v1puxLC56S 7GiBgbhwPNlOrIKYcFgT4GqxrrDCAUaQkPaGXUfvjol+geJTVxTxw4Ik+CBGHGQThx4vrqDBscQ vwplvv3BBs1N149HqJbhlZ6MF5XyRtH1y0UmY2xoN+G60vvmPP3J5ZcGBN6fBzLJfatoBZaMGTJ vh9p4IqYCaV4c/xXUYqjo2rfMDBDWSmFcVhAk7UuU5HN0M68AfLi0gJg+4/d6PfeFoEqhxYw9MP 8zA5d6aFIBjzpuv1URUkm2+0L9RrY+SeFlH03fZojxQ5qShfBf4GTcPeUpxGjXMI7TeaGLjMuWH nV8xAaqJ+GUzt3tud59LnZhpiUdjBBoMCmipO46mliVVK67cfWBdPSXrDAcVmKtWy7X/fx5Za50 y6pdjo0Ti9bXhrjSmROAzyRcQZVd4Tt76HNH6MgwzPivdlKmxsiEb9W3B1poA2d1KcwaHnCUBKw nQ64x9NUDb6PTfy+gcw16DHZmiCCqtPdlA1ifeyv27hZ111W8cHZ2VQO7jAg5JaRF4gzEIapsMj 5qvhv7R9zEgRaUQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 As Jakub pointed out, I meant to use a bitwise or after the call to nla_put_string. Also move the sunrpc_get_pool_mode call up in the function, which simplifies the error handling a bit. Cc: Jakub Kicinski Signed-off-by: Jeff Layton --- Technically, I think the logical or works just as well as a bitwise or here, but this is cleaner and maybe slightly more efficient. Chuck, it's probably best to squash this into 84a570328ee. --- fs/nfsd/nfsctl.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 187e9be77b78..e5d2cc74ef77 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -2214,6 +2214,9 @@ int nfsd_nl_pool_mode_get_doit(struct sk_buff *skb, struct genl_info *info) void *hdr; int err; + if (sunrpc_get_pool_mode(buf, ARRAY_SIZE(buf)) >= ARRAY_SIZE(buf)) + return -ERANGE; + skb = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_KERNEL); if (!skb) return -ENOMEM; @@ -2223,11 +2226,7 @@ int nfsd_nl_pool_mode_get_doit(struct sk_buff *skb, struct genl_info *info) if (!hdr) goto err_free_msg; - err = -ERANGE; - if (sunrpc_get_pool_mode(buf, ARRAY_SIZE(buf)) >= ARRAY_SIZE(buf)) - goto err_free_msg; - - err = nla_put_string(skb, NFSD_A_POOL_MODE_MODE, buf) || + err = nla_put_string(skb, NFSD_A_POOL_MODE_MODE, buf) | nla_put_u32(skb, NFSD_A_POOL_MODE_NPOOLS, nfsd_nrpools(net)); if (err) goto err_free_msg; --- base-commit: 84a570328eefd4df2e201deb5d43d152e0aca55a change-id: 20240614-nfsd-next-d5f6bbdf027d Best regards, -- Jeff Layton