From mboxrd@z Thu Jan 1 00:00:00 1970 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 CF7631C31 for ; Wed, 23 Nov 2022 09:42:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12319C433C1; Wed, 23 Nov 2022 09:42:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669196535; bh=Fm12baPjYoNch4H1j/diuKG6XzVUOnv//UMdldRP9EE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yJL1E5lFPpFcS+5fgxMK6EO3Djckf0UVm2LtC3EYu5KvgsZwjgathccAQduWZtCS+ mnV9lq3fBeE23jJIc5NwWV8HtO8b4cXNrR9Qf7HwmIaZe0aQlG/zU+spoqlxxURjAI DfKWcZFxjUhLHLIhYWUYFaFKVBv1u1t0kMK3Nwpo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yu Zhe , Dan Williams , Sasha Levin Subject: [PATCH 6.0 058/314] cxl/pmem: Use size_add() against integer overflow Date: Wed, 23 Nov 2022 09:48:23 +0100 Message-Id: <20221123084628.131829259@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221123084625.457073469@linuxfoundation.org> References: <20221123084625.457073469@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Yu Zhe [ Upstream commit 4f1aa35f1fb7d51b125487c835982af792697ecb ] "struct_size() + n" may cause a integer overflow, use size_add() to handle it. Signed-off-by: Yu Zhe Link: https://lore.kernel.org/r/20220927070247.23148-1-yuzhe@nfschina.com Signed-off-by: Dan Williams Signed-off-by: Sasha Levin --- drivers/cxl/pmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cxl/pmem.c b/drivers/cxl/pmem.c index faade12279f0..e0646097a3d4 100644 --- a/drivers/cxl/pmem.c +++ b/drivers/cxl/pmem.c @@ -151,7 +151,7 @@ static int cxl_pmem_set_config_data(struct cxl_dev_state *cxlds, return -EINVAL; /* 4-byte status follows the input data in the payload */ - if (struct_size(cmd, in_buf, cmd->in_length) + 4 > buf_len) + if (size_add(struct_size(cmd, in_buf, cmd->in_length), 4) > buf_len) return -EINVAL; set_lsa = -- 2.35.1