From mboxrd@z Thu Jan 1 00:00:00 1970 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 60A0EC4332F for ; Tue, 2 Nov 2021 22:22:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 39E5460E52 for ; Tue, 2 Nov 2021 22:22:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230293AbhKBWY6 (ORCPT ); Tue, 2 Nov 2021 18:24:58 -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-Google-Smtp-Source: ABdhPJzNzgeCRneEtl/OuRcnmdMRl0O3mLH2zosezbf53RYoTXXwpuQAhPCXODDFyBqJjToUhg2Muw== 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