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 2A70B1ED38 for ; Tue, 25 Jul 2023 11:35:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97A8EC433C7; Tue, 25 Jul 2023 11:35:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1690284905; bh=ab14gD6H3scgCzQQ7LjjFZg8OztyVspuUUuHxNBtT+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vtIMFCxUs+UCIoqWIcdictWvxol0PWfC50Qc4+Oj9sTPsIwzf5OQ7wMkNgBozV4A8 E1mqfxCa14paY+5OmCmUiJhhSaZQRqP+JWemUkTiz+XnWYWZOn4nRgyVZTR25oSkWM UgP+xoV/xWS+YgHaOb058c3jqcpJ1rjLu4nAWT2A= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Li Nan , Yu Kuai , Song Liu , Sasha Levin Subject: [PATCH 5.4 014/313] md/raid10: fix wrong setting of max_corr_read_errors Date: Tue, 25 Jul 2023 12:42:47 +0200 Message-ID: <20230725104521.778061326@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230725104521.167250627@linuxfoundation.org> References: <20230725104521.167250627@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: Li Nan [ Upstream commit f8b20a405428803bd9881881d8242c9d72c6b2b2 ] There is no input check when echo md/max_read_errors and overflow might occur. Add check of input number. Fixes: 1e50915fe0bb ("raid: improve MD/raid10 handling of correctable read errors.") Signed-off-by: Li Nan Reviewed-by: Yu Kuai Signed-off-by: Song Liu Link: https://lore.kernel.org/r/20230522072535.1523740-3-linan666@huaweicloud.com Signed-off-by: Sasha Levin --- drivers/md/md.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/md/md.c b/drivers/md/md.c index bae264aae3cd0..0765712513e7d 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -4441,6 +4441,8 @@ max_corrected_read_errors_store(struct mddev *mddev, const char *buf, size_t len rv = kstrtouint(buf, 10, &n); if (rv < 0) return rv; + if (n > INT_MAX) + return -EINVAL; atomic_set(&mddev->max_corr_read_errors, n); return len; } -- 2.39.2