Received: by 2002:ac8:4602:0:b0:405:464a:c27a with SMTP id p2csp2536251qtn; Tue, 25 Jul 2023 11:33:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlGM1A7FGsOyRNB77bp+I0AC1SP901TwG/I7Nn+7wa4kFR3zz3XwbVp2su1uCf5dgvLyF6Al X-Received: by 2002:a05:6a00:808:b0:682:37be:c9fe with SMTP id m8-20020a056a00080800b0068237bec9femr18574pfk.10.1690310013263; Tue, 25 Jul 2023 11:33:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690310013; cv=none; d=google.com; s=arc-20160816; b=YtDQg1jlY+l8YckmFbMXVbij/q1pMTBMbkES2cjubBbzXfNEUNM/aeowL6TsFpE0v4 fkexLuqOs5KMTJZMkS9ohyjYdhUkoXPuzXf5ZBj21T9N7X69blW3Ht8UHDE5pwPGdyJ4 qg2lFcJqdrIw+fjoR+EPBzsZaZA1hWAyFc4MZCIw9Z34FstAPXJpWhXwVBBtyZDZV8P9 qfXQ+0iIHyTqMrv1ieOpkVn5MTtfNg07A7Aat5D6JxIRpt2nBNUrr/NKLx6FwL8yNXFh Wq/ds3tMN9VNN+o6rnxqk7RKwMsvQ5CqdDTQT7bK5+3Nptc+9n4WLPm89mh6bm2zSBUq /Gbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=RfdbdDNr9lvtPioh6nTqIGvUGGU1L46kxvnNKym7qno=; fh=8nBWZbT6HMHubtHHd8IzkZgCrQUggc0mHHXc9tiMbbQ=; b=Azm7XoTo+QUKxc+HmnBXNmh3Ys5zm1oWjVCnBltrbY2fv4/panWwqMFYifa/M3vmZq xevhbV42jM/fkUnI1QmW0diAlXltWlDUa2dH4sFrYfscn028hgwEiXpncRQVLQsO+5pj WrvumJsGO8C0nUYoCfvEd84RG02mp0FmPkhRxqVFj8bIgIL8kH07BS2tCWf1rTyhuMJ8 Mh88fo/g9l/B0h5aHY9dKNd69ehdEIMuffi3oClyyNt5/m8jZKvKbo5w1QuwBU12PtrZ wUVCS0/QWFjSgWYAE2GnBzMmqAhHUSFR86NaejmoXEkrjE3zRkP3aOJkk6KZc5J2Hvj6 JfLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z3EWvYM5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j2-20020a056a00174200b00682ad3475e4si12316856pfc.209.2023.07.25.11.33.20; Tue, 25 Jul 2023 11:33:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z3EWvYM5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229959AbjGYR0t (ORCPT + 99 others); Tue, 25 Jul 2023 13:26:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjGYR0s (ORCPT ); Tue, 25 Jul 2023 13:26:48 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99CD21BDA for ; Tue, 25 Jul 2023 10:26:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690305965; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=RfdbdDNr9lvtPioh6nTqIGvUGGU1L46kxvnNKym7qno=; b=Z3EWvYM5sMuFYjFP7y342mj5HjP50ALH07XTbPVHN2yQwJ+459gWvmMxVlifESvvR9ceov BYlgZVVIMpXiXXn+joRLHkUBq1bUHDT9ai9fYfZd1lYpdUgIdPn5VPs07IIowhJJ45vP4u fPqOyZ0iZK9nk3OzWC6lOpKXmu0vHHY= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-283-OHXZMGCyMXOPHFdKEVYPvQ-1; Tue, 25 Jul 2023 13:26:03 -0400 X-MC-Unique: OHXZMGCyMXOPHFdKEVYPvQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6A8E51C09040; Tue, 25 Jul 2023 17:25:59 +0000 (UTC) Received: from rhel-developer-toolbox-latest (unknown [10.2.16.250]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 39BB1200B66C; Tue, 25 Jul 2023 17:25:56 +0000 (UTC) Date: Tue, 25 Jul 2023 10:25:54 -0700 From: Chris Leech To: Lin Ma Cc: lduncan@suse.com, michael.christie@oracle.com, jejb@linux.ibm.com, martin.petersen@oracle.com, vikas.chaudhary@qlogic.com, JBottomley@parallels.com, mchan@broadcom.com, benli@broadcom.com, ogerlitz@voltaire.com, open-iscsi@googlegroups.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] scsi: iscsi: Add length check for nlattr payload Message-ID: References: <20230725024529.428311-1-linma@zju.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230725024529.428311-1-linma@zju.edu.cn> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 25, 2023 at 10:45:29AM +0800, Lin Ma wrote: > The current NETLINK_ISCSI netlink parsing loop checks every nlmsg to > make sure the length is bigger than the sizeof(struct iscsi_uevent) and > then calls iscsi_if_recv_msg(...). > > nlh = nlmsg_hdr(skb); > if (nlh->nlmsg_len < sizeof(*nlh) + sizeof(*ev) || > skb->len < nlh->nlmsg_len) { > break; > } > ... > err = iscsi_if_recv_msg(skb, nlh, &group); > > Hence, in iscsi_if_recv_msg, the nlmsg_data can be safely converted to > iscsi_uevent as the length is already checked. > > However, in the following parsing, the length of nlattr payload is never > checked before the payload is converted to other data structures in some > consumers. A bad one for example is function iscsi_set_path(...) who > converts the payload to type iscsi_path without any checks. Thank you for doing the code review on this, I think these changes look good. Reviewed-by: Chris Leech