Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1034610ybi; Fri, 2 Aug 2019 08:17:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqz1IHPin8c0ygZ9k9I1mSBQEdQWZCllnPq01Q8GHfC+a2mnQsjfuGxgQa2SFXIcGHM6rLPX X-Received: by 2002:a17:902:2ae7:: with SMTP id j94mr131723749plb.270.1564759021545; Fri, 02 Aug 2019 08:17:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564759021; cv=none; d=google.com; s=arc-20160816; b=cpV9a4Zh4YmyRVcoJNnl8Eg+Utm+EpDxHzp8ZhS9Q5v7R8N6ztmUsSPZ2Vf7twjljx s2b0+1QY8MbFSBBezzpNvm7jhf3IXtrrV5RwqavGqIDq5aAVDfnae0w3Uon17l/TT9og VfATu4HAKeGq/+QRKbkWzRu36uEjiXstt1NPT6a7KLCtTAPeYlcZMIIsQRW02fDUj44y nbdaSr8T64mbR9vTTFNRTSjhVUv+NBRxZdA9nWQ7ieFovHAUFIEhOho+dNcKdiHPzw2r 81iTTmaH8cbOnuqkPTtE4RU5nivSYRCviywQgaAnQfQ4/JutfIOSWQX55lAm8MPI1+V+ TvSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RudpJ337OEwcwgGmNro/+wpR1R/xXYlt+DXO3qwgtsg=; b=z6VnlhorndfUpDxQ/59uja7zUsfibFvJM02oOB2uifFYaHsBXeyOjEbboQw+QvdY+m ZvGgzfSI20w+kJRcfaHFkqtCzKirdYdGZVPegJXI6gMwGWPyVeIvnfeUZirnQchI0E7q r0r7U9rCZF+TsG6jVd+eCACwrhrcTLuN3sgV0o24Or9zkXJXPBvEhcbMdjG7JbnBA1ow lWjQU2lWX287UtNzCxVVeye/TRsVItY+AOKOJnzwctZ1N05aoh2w/9ygE8cs0lPlgISn eZAUVH4ZS+sINEzC8tl38TsIqMINGg1a7l6pj1c7zUX6hU8iq48rDqhNaBdEoXwXpdk9 mpvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TJvDz4JP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x9si28433326plv.182.2019.08.02.08.16.15; Fri, 02 Aug 2019 08:17:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TJvDz4JP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390486AbfHBJdd (ORCPT + 99 others); Fri, 2 Aug 2019 05:33:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:32846 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390413AbfHBJd2 (ORCPT ); Fri, 2 Aug 2019 05:33:28 -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 8084021855; Fri, 2 Aug 2019 09:33:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564738408; bh=PPvA7ml7LFFB5y0n9lNb3gNkDyaZeZkeeFX6exxKxJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TJvDz4JPJEuctrNlQt7rd8P9U8p+oPnXYx93x0i5IobNZmlX3L3l+T4KNYjc6Em9L DZON+lexIAw/HzhQwEPA/rBtMwsMh1+bihMBFMTpPHqQqvDl9lLVRypI9M7iHOOzw6 AgtEltAAKZn1TUmWO54SwDot2M8x1VdMCoR8IQ3Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Denis Efremov , Willy Tarreau , Linus Torvalds , Sasha Levin Subject: [PATCH 4.4 075/158] floppy: fix out-of-bounds read in copy_buffer Date: Fri, 2 Aug 2019 11:28:16 +0200 Message-Id: <20190802092219.257002324@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092203.671944552@linuxfoundation.org> References: <20190802092203.671944552@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit da99466ac243f15fbba65bd261bfc75ffa1532b6 ] This fixes a global out-of-bounds read access in the copy_buffer function of the floppy driver. The FDDEFPRM ioctl allows one to set the geometry of a disk. The sect and head fields (unsigned int) of the floppy_drive structure are used to compute the max_sector (int) in the make_raw_rw_request function. It is possible to overflow the max_sector. Next, max_sector is passed to the copy_buffer function and used in one of the memcpy calls. An unprivileged user could trigger the bug if the device is accessible, but requires a floppy disk to be inserted. The patch adds the check for the .sect * .head multiplication for not overflowing in the set_geometry function. The bug was found by syzkaller. Signed-off-by: Denis Efremov Tested-by: Willy Tarreau Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/block/floppy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -3237,8 +3237,10 @@ static int set_geometry(unsigned int cmd int cnt; /* sanity checking for parameters. */ - if (g->sect <= 0 || - g->head <= 0 || + if ((int)g->sect <= 0 || + (int)g->head <= 0 || + /* check for overflow in max_sector */ + (int)(g->sect * g->head) <= 0 || /* check for zero in F_SECT_PER_TRACK */ (unsigned char)((g->sect << 2) >> FD_SIZECODE(g)) == 0 || g->track <= 0 || g->track > UDP->tracks >> STRETCH(g) ||