Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp759514img; Wed, 20 Mar 2019 10:15:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeKnk9MzopyEAJzP4iiwpJbSaq6pgkyZv2wNYqVkeKahpJnYSFBzLuZjM3GsGW9MIYa5su X-Received: by 2002:a17:902:1486:: with SMTP id k6mr9410657pla.3.1553102154395; Wed, 20 Mar 2019 10:15:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553102154; cv=none; d=google.com; s=arc-20160816; b=h6xuILcNpbN7Qf23gLBas6V65RtsywFTNA2Mds6Pqs3gWlpGVq+3Oydmzv2xBQIbaX nL7ZqUMIx7BtXPmc1X1j1r+P6SCr4gpMPQeZz248YwEqgqGcN/KD2nSHWl0X86nO4N4S 2jxOSU0AcRhVt8aq6gARCDdDGCv6J61plLT//wZU7p1nkeRE7NPX7/SkucVHYIdbAaoh y1GrcPn0XcwtvvKlBXeJYghYOxJJC8MCUSAGr1cxIMGB3RGIlPKAYuHR7KR/FOpjb/2V Ivb0i3kwK+S2hosutVyY/rjFpv5bBGyiYxqxf/XM8+DjKNS0nm6bB+c0KxFD101nknji oZYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=n+Z0rib5TrNtn6+D5lbhPcqsLThpkFkExyBgSixZiBc=; b=hDRSyqn9u74YhokOqzo4PX+K8OpsQVYi9AG7jDZWucOHgyh02kQ7GWoyi4Y+hTUGLz AlQdS+rUSGfWiwadUms5vlb1yDvnbfbT4IbgmjGnzSwFAySnwN8TqBOuuu3dMHr9544q ocDDBsn/DsniJ3RGt5KxIunDQvaoCf/pwKEcL+Ev6fgW0WhslX4T5gXqlOSNz8XVWlo4 vRjwtHD5Yg2odhJhgxSpsuoxm9a4SdPfJ9Ynfp1mf5wLO2oF/nhwRGtsuE9CjZA1IKKV lJUI0g9TOHXHbnP6GtRUti9uqZRdREaX0qAThjZw4qw0mjy+0V+4S+C7iknw5IZI/b+T VgOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cb2si2343353plb.201.2019.03.20.10.15.38; Wed, 20 Mar 2019 10:15:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727182AbfCTROH (ORCPT + 99 others); Wed, 20 Mar 2019 13:14:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40786 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726403AbfCTROH (ORCPT ); Wed, 20 Mar 2019 13:14:07 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F77FC0B6175; Wed, 20 Mar 2019 17:14:07 +0000 (UTC) Received: from [10.10.122.62] (ovpn-122-62.rdu2.redhat.com [10.10.122.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id A958626350; Wed, 20 Mar 2019 17:14:06 +0000 (UTC) Subject: Re: [PATCH][next] scsi: target: fix unsigned comparision with less than zero To: Colin King , "Martin K . Petersen" , linux-scsi@vger.kernel.org, target-devel@vger.kernel.org References: <20190320163709.28767-1-colin.king@canonical.com> Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org From: Mike Christie Message-ID: <5C9274D9.30706@redhat.com> Date: Wed, 20 Mar 2019 12:14:01 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20190320163709.28767-1-colin.king@canonical.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 20 Mar 2019 17:14:07 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/20/2019 11:37 AM, Colin King wrote: > From: Colin Ian King > > Currently an error return is being assigned to an unsigned > size_t varianle and then checked if the result is less than > zero which will always be false. Fix this by making ret What kernel version was this made against? For Martin's 5.2 queue branch, with these scsi changes it looks like strlcpy returns a size_t. And then below it looks like we compare the return value from that function to the buffer size and the max len of the string we support. We do not seem to check for less than zero. > ssize_t rather than a size_t. > > Fixes: 0322913cab79 ("scsi: target: Add device product id and revision configfs attributes") > Signed-off-by: Colin Ian King > --- > drivers/target/target_core_configfs.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c > index 8f3faef235b5..3fe79875b3ac 100644 > --- a/drivers/target/target_core_configfs.c > +++ b/drivers/target/target_core_configfs.c > @@ -1267,7 +1267,8 @@ static ssize_t target_wwn_vendor_id_store(struct config_item *item, > /* +2 to allow for a trailing (stripped) '\n' and null-terminator */ > unsigned char buf[INQUIRY_VENDOR_LEN + 2]; > char *stripped = NULL; > - size_t len, ret; > + size_t len; > + ssize_t ret; > > len = strlcpy(buf, page, sizeof(buf)); > if (len < sizeof(buf)) { > @@ -1322,7 +1323,8 @@ static ssize_t target_wwn_product_id_store(struct config_item *item, > /* +2 to allow for a trailing (stripped) '\n' and null-terminator */ > unsigned char buf[INQUIRY_MODEL_LEN + 2]; > char *stripped = NULL; > - size_t len, ret; > + size_t len; > + ssize_t ret; > > len = strlcpy(buf, page, sizeof(buf)); > if (len < sizeof(buf)) { > @@ -1377,7 +1379,8 @@ static ssize_t target_wwn_revision_store(struct config_item *item, > /* +2 to allow for a trailing (stripped) '\n' and null-terminator */ > unsigned char buf[INQUIRY_REVISION_LEN + 2]; > char *stripped = NULL; > - size_t len, ret; > + size_t len; > + ssize_t ret; > > len = strlcpy(buf, page, sizeof(buf)); > if (len < sizeof(buf)) { >