Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4753571pxb; Tue, 2 Nov 2021 15:23:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSdNqgrw6zlZtaPkHZTpJt6SbDY4jpc1+okDvGrWlY7ZxVSA+8doqQ4afj+r0FbH+esUSH X-Received: by 2002:a5d:9492:: with SMTP id v18mr27608589ioj.158.1635891827945; Tue, 02 Nov 2021 15:23:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635891827; cv=none; d=google.com; s=arc-20160816; b=FUBd9xuzm2SAyjzmKOeDwxbN+nug5ROxN+TNBKjg6NcxrWCTeK116FboOD1MgYF/wM AjkHfuH3M4wsPycozVXMrfZ7LRDnHnOnVZNYKN1WHCuOmPqY0YfLtEye99CxMhfUua1u qbhyNjMgRIEp2qfaH2Pz/XUQcaF3IpFe4DabKCjCdM8ljVCjPBf7LNYS54v5vkvtOIK/ vI/r4o3EpeM128zPDRP0bWceVTpTIgFycvsVHfW2v0s2LnnFxTeCJ8uiREryVf2iwMD+ aMEqlmHBmg7JV5n5BJIDKkU3lea0EPU7uMERg6VRfjGBZfAvcBLDLQNK1XqedntHqa7P 1fHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=j1DHSf7OFCAhcG6Ev4KJ21kqE/vBpcfBYIGy5Hss0OU=; b=tUhLQSrh5WYcEEe0Cx/nGlcqurBYwuI6JMMeXl7j9QgiM4STdkQ56OXlwqARQIZyJp gEPX1n9b9wnGgunTJO5j8HWPHWB6+uhmfTdbeHOIB2m9AUm8DcW3W68zg5gOu3upD64f SPW8+26twHFxn4NAmJHKWbiTciolq0IocXVSMnyCitW0IWYsc0WQpEexKPTrO5ZSyyVY 49RAw/IrLfAE3Hdw/D9hRMR5bNpC7+Ppwq2jqzafKzjqiWKrfxFX5f+uqgoQ1agqvIgS Ek4xrPi9JGb4qT/5w4kpivD5CfVig2M6oz3XMu7rd8IKOpJHEQMWAwkQtNM7aKYo24Zp jRgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KbIy8DPz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b14si530324ilv.20.2021.11.02.15.23.35; Tue, 02 Nov 2021 15:23:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KbIy8DPz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229736AbhKBWY5 (ORCPT + 99 others); Tue, 2 Nov 2021 18:24:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229672AbhKBWY4 (ORCPT ); Tue, 2 Nov 2021 18:24:56 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 115E7C061714 for ; Tue, 2 Nov 2021 15:22:21 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id r5so1108860pls.1 for ; Tue, 02 Nov 2021 15:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=j1DHSf7OFCAhcG6Ev4KJ21kqE/vBpcfBYIGy5Hss0OU=; b=KbIy8DPz7BelN4mQVIa0lcsRGU6Js24LddT3z3AFm+N/o5wou5dV5YqAIDqnzq4+tt LIJBLAJH8pjczuGamwxqmUOsApKplS/ryb+wwMN2rybQSRu8JYzkUVFuD8cNK9spVlqe EBJ6J8nviBhozNbO3krGbgaGpZB8YyvhkyaKW9kkiukid8H8R1SW+j6ih7xv6wsJ2md5 0Kx57w8wQ6iQeTiF/U//maoEkSIrIR67lz/hJnrimQvvgtjKxmiqu1VxyP4+7zrzOAyr +DRLPssX2DQ0LxlbXa0PR7AYTRVat6FC6ka9JUVHOfXwRRxf7FwxZlrwVKHjSxpE+OMI wLKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=j1DHSf7OFCAhcG6Ev4KJ21kqE/vBpcfBYIGy5Hss0OU=; b=pyQIrzBwdt7YoIZbxg+PcxwA4t6kMr7+qKNMADUmt4fqDTM/fB0ls6bzVeyivgPXFt lZkh2b10YYnMEHrkh3wywfMXeq0LWAWR/6YAFxDoBLe3L3hM5pIhkWTqj+nlvBdly9lD mYZ9JWwYJdcKHqyIdHIEGeLS2o0KE9UTYlhqMzziRCqUGHSPS5Wfe4x7xZ4koO1SLqum MoUvWeJMceQpN24pbLKLAiFlwWbikySzB1odHMIr++V8EnHKPfx5bTs6BycC4vasNBln TbSOlQ4cPbc7n3dEbHwGy8EzySqx4zPKyUXBoCWrR9awUCywFVh3le8gVp0kVsHmmrct Cnog== X-Gm-Message-State: AOAM530+IcssXNQJ3c28ERYq7kXqjBVxBqyg9Ft/lNeJ732EJYFUMvbk 8kugws6hPoNk5SSF2X8flhmL6g== X-Received: by 2002:a17:90b:3e81:: with SMTP id rj1mr10165734pjb.111.1635891740644; Tue, 02 Nov 2021 15:22:20 -0700 (PDT) Received: from [192.168.254.17] ([50.39.160.154]) by smtp.gmail.com with ESMTPSA id e8sm97040pgn.46.2021.11.02.15.22.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Nov 2021 15:22:20 -0700 (PDT) Message-ID: Date: Tue, 2 Nov 2021 15:22:19 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH] scsi: core: initialize cmd->cmnd before it is used Content-Language: en-US To: dgilbert@interlog.com, Bart Van Assche , linux-scsi@vger.kernel.org Cc: Christoph Hellwig , "James E . J . Bottomley" , "Martin K . Petersen" , linux-kernel@vger.kernel.org, stable@vger.kernel.org, syzbot+5516b30f5401d4dcbcae@syzkaller.appspotmail.com References: <20211101192417.324799-1-tadeusz.struk@linaro.org> <4cfa4049-aae5-51db-4ad2-b4c9db996525@acm.org> <0024e0e1-589c-e2cd-2468-f4af8ec1cb95@linaro.org> <8fbb619a-37b3-4890-37e0-b586bdee49d6@interlog.com> <17a1b72e-2c2a-8492-cb92-4dec36a6531d@acm.org> From: Tadeusz Struk In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/2/21 14:33, Douglas Gilbert wrote: >> Thanks for having taken a look. I found the above check in sg_new_write(). To >> me that function seems to come from a code path that is unrelated to sg_io(), >> the function shown in the call stack in the email at the start of this thread. >> Maybe I overlooked something but I haven't found a minimum size check for >> hdr->cmd_len in sg_io() before the blk_execute_rq() call. Should such a check >> perhaps be added? > > I guess it came from ioctl(, SG_IO, ) and I found no lower bound > check when I looked in lk 5.15.0 . No-one has complained to me about the >    hp->cmd_len < 6 > > check in the sg driver ***. So I think such a check may be useful in the > scsi_fill_sghdr_rq() function in drivers/scsi/scsi_ioctl.c . And a return > of -EMSGSIZE seems to be tailor made for this situation. > > Doug Gilbert > > > *** It is possible a vendor specific command could be between 1 and 5 bytes > long, but that would probably be an unwise choice. Bart, Do you want me to send a patch with the check in scsi_fill_sghdr_rq()? I want to close the mentioned syzbot issue in 5.10. I can also do the back-porting if anything will be required. -- Thanks, Tadeusz