Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1010867imu; Fri, 11 Jan 2019 13:14:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Pe+34NBaLuNAzbDodkbofo7neOF8lKVfij9iGtnlzJ6tUxdq6UYhz8nNkwVUKiiSpu2R8 X-Received: by 2002:a63:d252:: with SMTP id t18mr14877684pgi.133.1547241253694; Fri, 11 Jan 2019 13:14:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547241253; cv=none; d=google.com; s=arc-20160816; b=FzEH7ewAm53I/+bKCG8biTYP0AqE4zsMUbrgzYsduHT6bvV8YiOnfGMwZQ6MIQ4YcC NRgNjIc18cUfWVckKe5eBDVl9V/suxXqTrNr6oV7d2Bye4+PEHXD2CjURtGnz2EKk4K5 jPwFtT/PqyhYwlHpmYfQlGRk2wS9xfbElbjp8Wq9KAUiJj55C7trQpdU8MTun5boQVID ylGb+9stMRqOYYIl9lpC1v4eJYdn+OHVvUmbEkxrsKm6vzgqk+YXrMJehijTOGoNDAyM y5VW9m8Yaicd5w8H/Fip7moRJj87AKuyfpD4T7q1UeeZBz0P8dDh5TUQgOjRXr/bdiNP 04Rw== 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=Muka8ZLC6gRyQ8izgbbQx/U4EG4EvkrxvUjSA0AQXc4=; b=AOsNsnbRtuFeTNsxCdpSmjY6+x9O2fIRC0qicaTTOzoEC+pX8FnOx1rroQuveIVFym YDkl2EjOL14Qj0TVRpVAHwREst4Xc109/mbj0eSiPrYSSeDafWGSpW3r4IVMkNyWnPRO bZK3QxAL+QAb5vcVk1ORFbfRxOL/bvyMEzrRwohRdcC74/+B59SMe9mIOjaKlks0F5Ln ykc0k6XZfA0GMqHhbcfEP1DHRzduS2s6cq16SrnBmZmFCJyOfIOW4ujzZNQjpnQ89see +t8H9hxHWaBGu7Ob7KQoBtCqO9MtqW89UImMl31g+WmKcANZrmR0bEQLb179ryO8/ZhB z0ZQ== 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 n125si13514959pga.179.2019.01.11.13.13.58; Fri, 11 Jan 2019 13:14:13 -0800 (PST) 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 S2388900AbfAKUGF (ORCPT + 99 others); Fri, 11 Jan 2019 15:06:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52640 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730271AbfAKUGF (ORCPT ); Fri, 11 Jan 2019 15:06:05 -0500 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 2E46490C7A; Fri, 11 Jan 2019 20:06:05 +0000 (UTC) Received: from [10.10.125.65] (ovpn-125-65.rdu2.redhat.com [10.10.125.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0AF0326368; Fri, 11 Jan 2019 20:06:03 +0000 (UTC) Subject: Re: [PATCH] target: fix a missing check for match_int To: Kangjie Lu References: <20181226064818.75984-1-kjlu@umn.edu> Cc: pakki001@umn.edu, "Nicholas A. Bellinger" , linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-kernel@vger.kernel.org From: Mike Christie Message-ID: <5C38F72B.5000203@redhat.com> Date: Fri, 11 Jan 2019 14:06:03 -0600 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: <20181226064818.75984-1-kjlu@umn.edu> Content-Type: text/plain; charset=windows-1252 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.29]); Fri, 11 Jan 2019 20:06:05 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/26/2018 12:48 AM, Kangjie Lu wrote: > When match_int fails, "arg" is left uninitialized and may contain random > value, thus should not be used. > The fix checks if match_int fails, and if so, break. > > Signed-off-by: Kangjie Lu > --- > drivers/target/target_core_rd.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c > index a6e8106abd6f..3138123143e8 100644 > --- a/drivers/target/target_core_rd.c > +++ b/drivers/target/target_core_rd.c > @@ -573,7 +573,8 @@ static ssize_t rd_set_configfs_dev_params(struct se_device *dev, > token = match_token(ptr, tokens, args); > switch (token) { > case Opt_rd_pages: > - match_int(args, &arg); > + if (match_int(args, &arg)) > + break; I think if this fails you would want to return an error. Also, I think you want to add a similar check for the Opt_rd_nullio call below this chunk because arg may initialized to junk. > rd_dev->rd_page_count = arg; > pr_debug("RAMDISK: Referencing Page" > " Count: %u\n", rd_dev->rd_page_count); >