From patchwork Wed May 10 21:07:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 9720693 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5BE646035D for ; Wed, 10 May 2017 21:19:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E8372863E for ; Wed, 10 May 2017 21:19:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 624A528645; Wed, 10 May 2017 21:19:59 +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=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable 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 1DD372863E for ; Wed, 10 May 2017 21:19:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752874AbdEJVT6 (ORCPT ); Wed, 10 May 2017 17:19:58 -0400 Received: from a2nlsmtp01-03.prod.iad2.secureserver.net ([198.71.225.37]:36554 "EHLO a2nlsmtp01-03.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751039AbdEJVT5 (ORCPT ); Wed, 10 May 2017 17:19:57 -0400 X-Greylist: delayed 676 seconds by postgrey-1.27 at vger.kernel.org; Wed, 10 May 2017 17:19:57 EDT Received: from linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id 8Ypgdj54R7V0N8YpgdaBQz; Wed, 10 May 2017 14:07:40 -0700 x-originating-ip: 107.180.71.197 Received: from longli by linuxonhyperv.com with local (Exim 4.89) (envelope-from ) id 1d8Ypf-0000ld-Ux; Wed, 10 May 2017 14:07:40 -0700 From: Long Li To: "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Long Li Subject: [PATCH] scsi: zero per-cmd driver data for each MQ I/O Date: Wed, 10 May 2017 14:07:23 -0700 Message-Id: <1494450443-2921-1-git-send-email-longli@exchange.microsoft.com> X-Mailer: git-send-email 1.7.1 X-CMAE-Envelope: MS4wfMJ/TP+wwUh+0YW2K3qvgE32O5IMP7kjO8u7vAgC1BW9tff7AnNMdu36pkhHfddjdryvHsPYfuyokRjCIfFLestBqPWzpTRA+MUz6xBy05Y4HwvC9jVn fQD4zbwm/bt1CxE4AgOI1w6mOcAqDcexLOspuPjy5w5X2qKkJZ1t2cEvnHflnnhTi0y+8xUyXggNs5KVXgE8mRtxi0SX+8r4pVtaxeEjVxZiFCtxXy2if/nW Ro04PyXlhPcQUwu2bqU8+VKNFXnkeb1ZguHvps2qYJC9xKfvrnq4XLb5hME03vRhNZG81EGzL2NjaL6+ot68Z8uT5XPL0DgS3xW6Hfv3QFM= 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 From: Long Li Lower layer driver may not initialize private data before use. Zero them out to prevent use of stale data. Signed-off-by: Long Li Reviewed-by: K. Y. Srinivasan Reviewed-by: Christoph Hellwig --- drivers/scsi/scsi_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 19125d7..a821593 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1850,7 +1850,7 @@ static int scsi_mq_prep_fn(struct request *req) /* zero out the cmd, except for the embedded scsi_request */ memset((char *)cmd + sizeof(cmd->req), 0, - sizeof(*cmd) - sizeof(cmd->req)); + sizeof(*cmd) - sizeof(cmd->req) + shost->hostt->cmd_size); req->special = cmd;