From patchwork Tue Dec 25 21:26:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Lu X-Patchwork-Id: 10742709 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2F1B8746 for ; Tue, 25 Dec 2018 21:26:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F18D27FB1 for ; Tue, 25 Dec 2018 21:26:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 106522864B; Tue, 25 Dec 2018 21:26:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B06B327FB1 for ; Tue, 25 Dec 2018 21:26:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725913AbeLYV0l (ORCPT ); Tue, 25 Dec 2018 16:26:41 -0500 Received: from mta-p7.oit.umn.edu ([134.84.196.207]:46676 "EHLO mta-p7.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725870AbeLYV0k (ORCPT ); Tue, 25 Dec 2018 16:26:40 -0500 Received: from localhost (unknown [127.0.0.1]) by mta-p7.oit.umn.edu (Postfix) with ESMTP id F008473A for ; Tue, 25 Dec 2018 21:26:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p7.oit.umn.edu ([127.0.0.1]) by localhost (mta-p7.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4TofIij26JsX for ; Tue, 25 Dec 2018 15:26:38 -0600 (CST) Received: from mail-it1-f200.google.com (mail-it1-f200.google.com [209.85.166.200]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p7.oit.umn.edu (Postfix) with ESMTPS id BF8EFAE6 for ; Tue, 25 Dec 2018 15:26:38 -0600 (CST) Received: by mail-it1-f200.google.com with SMTP id x3so16992773itb.6 for ; Tue, 25 Dec 2018 13:26:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=YZ/ut4gelaWAVFYeFqfM3A/J9UTKw9HJjR1xfSAeaog=; b=eap7N3hTSbg6iwBzyXcc0MErmo0zpE/cpBQN9sUEMNElpLdEoNyf+3V7qcj/tPgVlg znwClg6xqnFaSE/a6p8nH71IA2I5mcfPck9o4MuqEZuH3lGElHK80gnL4SHmAiEWvO7+ 8iH8GzLiFuEJAfQmD7I6RYZFovd2/KYxFXEsB3Z0iyLJqoSQp8dmOQIZ/2xyIjSlXt3O 4+w6Bw69UitGM4897cm1vpdukcKYEcapnpAPgceVtg3il1p+4+chwN4q6iE/6sA4WlwX xV6OgYZjrj8vPx20doum0dw7i+/XyIrvah+xX3SrXdu/dZTx5LsfRS8MUnKzP2tt0kf7 uX7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=YZ/ut4gelaWAVFYeFqfM3A/J9UTKw9HJjR1xfSAeaog=; b=fmMMpO0gqLUD8eksP0fwgpZYG1wg1shLobKpRzqtc0QOP0xp089Hi2QPRfqFEMw/ab fYm3BrtsFBh5+Dh8a/MISzJ+Q/i1z6whTAtUZmZ3Fidhmy9TCS4MfRK1oE0sk3CZoo9t F3Md6TVXGcOaU1s5D53ppjqHyJZ2libZVFAYAVlN7jRxMXD+NG/MrgUl36n4DP2zoOD4 /FOZyY+o5T7US/U/2WLY7SMZRx/PdlUz4VZoum2JC8szH0fcKhTENdzBwVnegFfehDzL nh6BzoMgZ2IpirDiHPspUeN9nzcBMrtNBCc+iDUwrhk+dtA99KPwJDL1PYsYNNLwmjXn bxqQ== X-Gm-Message-State: AJcUukfuwy1UvLKgyC8htbBmXPZ9/NeXpg0swPXlpVFSTLluf+EZCcmM SKMiTT15KLDpG9ptIZCJ1KN3kTy+Lj7eAhW92PS0wX7ZFf5OoxLSUVp6i+DNhb1VrlUfZF380aM yLNrFhDzSlOwKRszWzw7GL30caw== X-Received: by 2002:a6b:2c92:: with SMTP id s140mr11690251ios.218.1545773197972; Tue, 25 Dec 2018 13:26:37 -0800 (PST) X-Google-Smtp-Source: ALg8bN5nXPyjgdXbLk7lzFUEX2KvGjr5133d4Rnwcs279saXt0vH0hwuxgFwm0qz3LLsiwRnMvzlJQ== X-Received: by 2002:a6b:2c92:: with SMTP id s140mr11690241ios.218.1545773197751; Tue, 25 Dec 2018 13:26:37 -0800 (PST) Received: from localhost.localdomain (host-173-230-104-22.mnmigsc.mn.minneapolis.us.clients.pavlovmedia.net. [173.230.104.22]) by smtp.gmail.com with ESMTPSA id n124sm13164874itn.4.2018.12.25.13.26.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Dec 2018 13:26:37 -0800 (PST) From: Kangjie Lu To: kjlu@umn.edu Cc: pakki001@umn.edu, Adaptec OEM Raid Solutions , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: a potential double-fetch bug when copying msg Date: Tue, 25 Dec 2018 15:26:09 -0600 Message-Id: <20181225212609.69856-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.2 (Apple Git-113) Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP user_msg[0] is copied in twice from user space. It contains size and is critical. The fix ensures it is not changed in the second copy. Signed-off-by: Kangjie Lu --- drivers/scsi/dpt_i2o.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index 93bd1d1bd5b5..2294520842e0 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c @@ -1850,6 +1850,8 @@ static int adpt_i2o_passthru(adpt_hba* pHba, u32 __user *arg) rcode = -EFAULT; goto cleanup; } + /* Ensure it is not changed in the second copy */ + msg[0] = size; sg_count = (size - sg_offset*4) / sizeof(struct sg_simple_element); // TODO add 64 bit API