Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp205359pxj; Tue, 18 May 2021 01:13:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzo+vhR4h6wo8KWAQtFB0Om+zmvMot0cBMdPXe+2gvGRSXJbvanPNvJ4Nz7cBDUZMrEfHAd X-Received: by 2002:a02:3505:: with SMTP id k5mr4211663jaa.123.1621325587317; Tue, 18 May 2021 01:13:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621325587; cv=none; d=google.com; s=arc-20160816; b=bNb7XNfXzFGzhyqswJFsVwKE49rC1r0PXrrG3CaN9MgIYokMSVGAXdiQy9vGXB9R0b 0dOBGQU0MlQcUBy3/sfmZCgaQZsoqrQJIGbiehXb4PLHbrriUWZpiqeW8CawWM7p3HiF /Glk/UOv+S89IePf+rILZJcuNFsAzqZblbk4xSspL2MFxI9HveJ44nvwyfAnOl5+dfaN FOEkB53/uID+v53a3OFx0J29EHrJZKF2egLN1FcKepEGEX8YKnGn8ULAyILDGf7hqaMo iB8FnFiOfcD2OaS0G93OfuuJSjltN+zDg0qe0dOHGB2gDgAt9HmIn5JaNQHC6WRlFXym QtHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bNZVQAoLusSlddayFaqXA7CDTYLGk3ijXzGoKD9SgF8=; b=H3j+p24GwBd3zfKn4vWoAEJyBUd4/JJKRqXI1mQrb+4Fb4MJHAaCj89NQgTar3b17w 2CuAOdBU61bCd21zWtWsLJASzzP8Mgw74AcakehLtGx8R6urNTeJpHvQuATsrlGf6NF5 +nnXpEb3dva7OLt8HCIS6m3ikHwMwjQV/uD2ISm8Le06BLhLOBBbeg751ugqlufTSTEP 0XYyAkWR0KqQXdZ2FuS1+oELQYic5MbO6fuswMCjBN2rSKnY0BN9fk1C12yvCd4etekF eyXt937BMDRPY2YC2whsrSxW/jSCYKi9E3BZcB1+YhkVCS5GGJMEvwI6SoLqbb/9zfaN 1Ucg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v86S3mwZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b14si22185804ilv.52.2021.05.18.01.12.47; Tue, 18 May 2021 01:13:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v86S3mwZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242292AbhEQO70 (ORCPT + 99 others); Mon, 17 May 2021 10:59:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:37928 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242134AbhEQOt6 (ORCPT ); Mon, 17 May 2021 10:49:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D715E613BE; Mon, 17 May 2021 14:23:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261382; bh=zD/XlO3nFglcr4ayUhe59PHYI1gbpAn+M8Dg02aSF6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v86S3mwZgG6i0MGkibSd5voiKealLxrqkKtYxgOInmxClFEBOk/euz/WcrRF9ftB5 9lUTx63KLUv5gpOQaxP8JinfrXsl4QGAfGCPiPuGm/TWAPnveRfhWLpCSXGFCJzi34 papWh7Z5GlOKWGvfpSJTaEjGQ6kVdkLy2rwATO7o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Aring , David Teigland , Sasha Levin Subject: [PATCH 5.10 014/289] fs: dlm: check on minimum msglen size Date: Mon, 17 May 2021 15:58:59 +0200 Message-Id: <20210517140305.659710659@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Aring [ Upstream commit 710176e8363f269c6ecd73d203973b31ace119d3 ] This patch adds an additional check for minimum dlm header size which is an invalid dlm message and signals a broken stream. A msglen field cannot be less than the dlm header size because the field is inclusive header lengths. Signed-off-by: Alexander Aring Signed-off-by: David Teigland Signed-off-by: Sasha Levin --- fs/dlm/midcomms.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/dlm/midcomms.c b/fs/dlm/midcomms.c index fde3a6afe4be..0bedfa8606a2 100644 --- a/fs/dlm/midcomms.c +++ b/fs/dlm/midcomms.c @@ -49,9 +49,10 @@ int dlm_process_incoming_buffer(int nodeid, unsigned char *buf, int len) * cannot deliver this message to upper layers */ msglen = get_unaligned_le16(&hd->h_length); - if (msglen > DEFAULT_BUFFER_SIZE) { - log_print("received invalid length header: %u, will abort message parsing", - msglen); + if (msglen > DEFAULT_BUFFER_SIZE || + msglen < sizeof(struct dlm_header)) { + log_print("received invalid length header: %u from node %d, will abort message parsing", + msglen, nodeid); return -EBADMSG; } -- 2.30.2