From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B40AC43381 for ; Fri, 22 Mar 2019 13:06:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 620C5213F2 for ; Fri, 22 Mar 2019 13:06:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553260013; bh=ied5yJSNtajlcy7nSMoskGfMkeo+nM8ek7mVYxSn5vQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=JKIjwmIo/PgDtpBjqiC/AAOzts4A6NCfA0pypstQiIhBsk4fVGT3bJRZ4qdj11x5Z qAqh/SrQ879IF6o03fHVz+0BXhQW5ucf8xjJbLD+dHwCZKl2NLSjS52YOp1l7nf7ih 5Fj83s2jVaL1iNE0QPEDUC9adCZ5hilWXZYEKo/Q= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730795AbfCVLhH (ORCPT ); Fri, 22 Mar 2019 07:37:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:38576 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730771AbfCVLhF (ORCPT ); Fri, 22 Mar 2019 07:37:05 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 21C6B21934; Fri, 22 Mar 2019 11:37:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553254624; bh=ied5yJSNtajlcy7nSMoskGfMkeo+nM8ek7mVYxSn5vQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0cZy3vivffmToOY4i9B2fH7sdeoUZhAy9ya6Algf/goofqL14C6oI1e408G8W6vVo 8RCSj3mtI8JlRG27C/avc4kYU95Egj+A1ww5OCs5LKkRFpEsxq4cI9N27onJAG2i5m JogVXHOREMUK/kO8k+2cnj7UNSlQ/bmHZOzgFQwM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Shishkin Subject: [PATCH 4.4 177/230] stm class: Prevent division by zero Date: Fri, 22 Mar 2019 12:15:15 +0100 Message-Id: <20190322111249.165701465@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111236.796964179@linuxfoundation.org> References: <20190322111236.796964179@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexander Shishkin commit bf7cbaae0831252b416f375ca9b1027ecd4642dd upstream. Using STP_POLICY_ID_SET ioctl command with dummy_stm device, or any STM device that supplies zero mmio channel size, will trigger a division by zero bug in the kernel. Prevent this by disallowing channel widths other than 1 for such devices. Signed-off-by: Alexander Shishkin Fixes: 7bd1d4093c2f ("stm class: Introduce an abstraction for System Trace Module devices") CC: stable@vger.kernel.org # v4.4+ Signed-off-by: Greg Kroah-Hartman --- drivers/hwtracing/stm/core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/hwtracing/stm/core.c +++ b/drivers/hwtracing/stm/core.c @@ -477,7 +477,7 @@ static int stm_char_policy_set_ioctl(str { struct stm_device *stm = stmf->stm; struct stp_policy_id *id; - int ret = -EINVAL; + int ret = -EINVAL, wlimit = 1; u32 size; if (stmf->output.nr_chans) @@ -505,8 +505,10 @@ static int stm_char_policy_set_ioctl(str if (id->__reserved_0 || id->__reserved_1) goto err_free; - if (id->width < 1 || - id->width > PAGE_SIZE / stm->data->sw_mmiosz) + if (stm->data->sw_mmiosz) + wlimit = PAGE_SIZE / stm->data->sw_mmiosz; + + if (id->width < 1 || id->width > wlimit) goto err_free; ret = stm_file_assign(stmf, id->id, id->width);