Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2397514lqp; Sun, 24 Mar 2024 17:44:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXpboWp5I3e+xcSrMAs4NztOQ2Ey+Dk6u66gwopJnVATHMfCbxZ14+WN77OijtrScnb87NRvbWHIL209rC2mJTwhEJCGWz2a7bHuGAUhw== X-Google-Smtp-Source: AGHT+IFQz0Lf+zQ3B8a9M3HkjWcvJDj/j5wAQ/nQbhTpCvJ6jlZhKWjomwuITwGJ84sqOrWXgIOD X-Received: by 2002:ac8:5a8c:0:b0:430:d0b6:e814 with SMTP id c12-20020ac85a8c000000b00430d0b6e814mr6717114qtc.19.1711327460794; Sun, 24 Mar 2024 17:44:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711327460; cv=pass; d=google.com; s=arc-20160816; b=exayNFFRSTke+G9Iwa/lqGH4SO+6nDuPvPD+VPoRCYfklpcIyfBQmOiQ2kB1NB2ujD eSSDK5rNlM2+WAZVBihxQ/JPLwPcw13GJnz5TjfSa8h4QBebze1tPIuM4AaHAmNSPPtq FoPWkgBn1rMbcR9K4zQq8oc8iT68rlA57NibvxY4U2JtcX3ZsZDIP5jix9lZwdd4fs4M r2KDph4ZZgDaPust+6kgWg8GVbXEnPCyKhib8IRqyffnFxTZlIX4ZbY1XeWALnFGIUKR H0gwbcVMbF45s6GGuHBzZCxM0QZNHNUyl3LWq8HLvBr5RXDLbzpQdNGx0qMNmVQlkPoD 7Zpg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=8krFL2RJA/Bvh1Nv+FPnnaBP1947P+kLKSJGAwzrLUk=; fh=mbIwtP6Z3WHtZxItIYvYhMbpONl+h48vFqSOX4Eg0x8=; b=Fp4PCLNFIRDry4zsaNFzpmqcYb0jEJ1pcp2i3YIj0IqJ3u3P4eIbMEvqeZf2zcX9po RWMMBOsD4Ax738gP5NAKZI/SYFrPOV2z1XkTIMdGDPsNMBLTFmOtXVzawM8WRWgrZznA m+xNkqKtapQsrkV3m3AzUoi1HYemAyur3v3hx3rsmQ9RJWofj0GxOUfOukQzlKl8lNpH ULaNfAoSOAV54Yh9oBGQWXqbb3kutBXt9t3Hq+9LlEPuEm/znhnlaYxY2urhbQ79a4sj 51B9Bfz1VhLOKylmzzGngSX79LNLLWaIZK2BTcd50Y1ZPNocQFGVV0XxEcEqvt58ggkG m5Eg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Rb+idTpj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113467-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113467-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 v3-20020a05622a188300b00430a445e7e9si4279401qtc.395.2024.03.24.17.44.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:44:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113467-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=Rb+idTpj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113467-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113467-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 86D551C23E4D for ; Mon, 25 Mar 2024 00:44:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 296CF1B2F77; Sun, 24 Mar 2024 22:44:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Rb+idTpj" 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 3C2B371752; Sun, 24 Mar 2024 22:44:28 +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=1711320268; cv=none; b=j64Uz44WmZhhQ828wh5mvJucz3DInYk4Zl5FPzgFfMP3RjBKc4RIJ+k4v8fJLaPOPlvkcTpMfaDnAuZI0QpvdZ4Vv4lDL0SYPqEHZM1wef2iLmz3BRaRzD8UBzraCLjkLbRPHVM+ixvtaW9sPXBLIW7NzRC7m+ET5bLVGc+hPXk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320268; c=relaxed/simple; bh=dhKFxGipNUYb7+OZCcYXRa1jL6XDpWTD56tS1MNSVQM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I0xR/ToZcfmHTT2xBm2IwILUu+TmDSvjUpWoEHFdWQ5OBXftmGiO4dqm7H3jmGKcy/iSY1VopiezgTbeXtzoC3WbeE86Nvq8y9gjJb0FDcDbxQnTnsDWQTpL3TDT7QhAVWkGdIkVMQAO0NSIxOnsyrQP5s0heM+pe1W3m4Zx43c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Rb+idTpj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65F05C433F1; Sun, 24 Mar 2024 22:44:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320268; bh=dhKFxGipNUYb7+OZCcYXRa1jL6XDpWTD56tS1MNSVQM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rb+idTpj4RW9RlugWYCHBalPhvD9t5p9m58YbnJzrN1zkDbiLFtCGeIPpE6Jj3p1q DDE9x80DKCdebQC03zwP1guZQjiR51y4qedyJ/xDGX26YqTI/xu5M1H0rPH3G0N80Z BBGcCS7NQH6KXFXIGdSEAvX6hpsNUA9TEla4rJPRJs2jVHBT9mJNERUUS0Z4lGM15V wfzRXM66+VR95WIMavd4BL5nrhCuI6tL/qODgmCkDbo0XbcwffAbBdVG8svCx7yzRM diGreG474Vvjnmqs2l0VHGgNazVL9vvWJSnkGWe+OQJ1CwZ7ocaXOlWJlSLi/KF4QV RBXqgVlhM73cA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christophe JAILLET , Benjamin Coddington , Trond Myklebust , Sasha Levin Subject: [PATCH 6.8 576/715] net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr() Date: Sun, 24 Mar 2024 18:32:35 -0400 Message-ID: <20240324223455.1342824-577-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Christophe JAILLET [ Upstream commit d6f4de70f73a106986ee315d7d512539f2f3303a ] The intent is to check if the strings' are truncated or not. So, >= should be used instead of >, because strlcat() and snprintf() return the length of the output, excluding the trailing NULL. Fixes: a02d69261134 ("SUNRPC: Provide functions for managing universal addresses") Signed-off-by: Christophe JAILLET Reviewed-by: Benjamin Coddington Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- net/sunrpc/addr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/sunrpc/addr.c b/net/sunrpc/addr.c index d435bffc61999..97ff11973c493 100644 --- a/net/sunrpc/addr.c +++ b/net/sunrpc/addr.c @@ -284,10 +284,10 @@ char *rpc_sockaddr2uaddr(const struct sockaddr *sap, gfp_t gfp_flags) } if (snprintf(portbuf, sizeof(portbuf), - ".%u.%u", port >> 8, port & 0xff) > (int)sizeof(portbuf)) + ".%u.%u", port >> 8, port & 0xff) >= (int)sizeof(portbuf)) return NULL; - if (strlcat(addrbuf, portbuf, sizeof(addrbuf)) > sizeof(addrbuf)) + if (strlcat(addrbuf, portbuf, sizeof(addrbuf)) >= sizeof(addrbuf)) return NULL; return kstrdup(addrbuf, gfp_flags); -- 2.43.0