From patchwork Mon Nov 15 16:51:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 12621021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC259C4332F for ; Tue, 16 Nov 2021 01:07:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A0FC61350 for ; Tue, 16 Nov 2021 01:07:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347930AbhKPBKG (ORCPT ); Mon, 15 Nov 2021 20:10:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:44626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245194AbhKOTTs (ORCPT ); Mon, 15 Nov 2021 14:19:48 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 444526350C; Mon, 15 Nov 2021 18:30:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1637001001; bh=78izC+EZ0Xm7pkJvK6mS30SX7oQaf2saG1JoY+1BYkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nk52kEOh2GAIbYWiPGP06dOmovrljBvLJ9QhPXByqMDHiirja2y2itlFHY+ILzJ9Q vuYY2/ShBRDdHEM32vRTPIsSwbWg2QIXNgQsFrT6u5tyai+xbkpL1zJO5dgrP+Ypyv MuyTEE2TQJK6hVdfEBuKS3TkNIMhCTwdo3GdHEJ0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bart Van Assche , Christoph Hellwig , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, Tadeusz Struk Subject: [PATCH 5.15 008/917] scsi: scsi_ioctl: Validate command size Date: Mon, 15 Nov 2021 17:51:43 +0100 Message-Id: <20211115165429.011122705@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211115165428.722074685@linuxfoundation.org> References: <20211115165428.722074685@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Tadeusz Struk commit 20aaef52eb08f1d987d46ad26edb8f142f74d83a upstream. Need to make sure the command size is valid before copying the command from user space. Link: https://lore.kernel.org/r/20211103170659.22151-1-tadeusz.struk@linaro.org Cc: Bart Van Assche Cc: Christoph Hellwig Cc: James E.J. Bottomley Cc: Martin K. Petersen Cc: Cc: Cc: # 5.15, 5.14, 5.10 Signed-off-by: Tadeusz Struk Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/scsi_ioctl.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c @@ -347,6 +347,8 @@ static int scsi_fill_sghdr_rq(struct scs { struct scsi_request *req = scsi_req(rq); + if (hdr->cmd_len < 6) + return -EMSGSIZE; if (copy_from_user(req->cmd, hdr->cmdp, hdr->cmd_len)) return -EFAULT; if (!scsi_cmd_allowed(req->cmd, mode))