Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3288944imm; Thu, 17 May 2018 06:33:01 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrwRaskOIxFmuQ31I8XWWY564VUK2QX+P1P53N+0P4hfeIoWh0CH9Bc8s8TMfprzWncxWTp X-Received: by 2002:a17:902:43:: with SMTP id 61-v6mr5343079pla.112.1526563981665; Thu, 17 May 2018 06:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526563981; cv=none; d=google.com; s=arc-20160816; b=l2dKV6PjWM7zVHGiUaq4aX+oXi461iM3z9s50/BfrrSEc/2JEDZdhJ0OOB0Kog/yD4 Z1G08gniHMe6p3Zn2jJy1lrp4tG1tN3oRebIhQs49nAVCEeXX7TdnLe3unC6+ODf0p8e g+lBNdKqcRtvaLBHpKSTgC1wI/EJ5XUAe2WcPBEmMgrkXLmv1OP66tdnJTaDXx3w1t+s gCC7WjwDdJgSWExf6sN4LGdu+IX2t8/70JkD6EhsNJx2N7CB7q3J+pOx2ogDj9RqccIR OHbkANXbs9utGwrpRAIImUOTrmWfSkCw+K7kR+shnjJLhHtrHgIwAsVMZxrhB58CXDJp REKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=Nt70djOL729f2pZKM3rM7dXctz/XtZIntF3GoOPvqmc=; b=pJ1PjQpSIKeim6CTxRS27K0ApLErXdjJsBV0A8wAbFH+cmEnEV4Sgxfxt2EvuHjUz1 haTfRR4vDl41lLWklf2sfST/EpoiZ1BKrohb6fKb4No+MJkytlwi9wUlA2+qVLiFxlpl xXxWKHZU1nY07zew3WIPnLNMpTOWoigU7Hrtpq6jrxpYCSAgXrKXVVJvI8FSwlSi4pBo 7AO7uJdDajG5wrp/s9ovhSKoN3NWRoOjmWxHWTSrsIMdGH1EvB4/KFCH8uVj3jVuYQZD l7R04GLz/MKjuiD0atNEj+3M2GRFd84WbFZK6hISWoj6+mfupIa8qjt00S1xL+KMqmBj sp1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a4JqT1CS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o63-v6si5083906pfg.5.2018.05.17.06.32.16; Thu, 17 May 2018 06:33:01 -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; dkim=pass header.i=@linaro.org header.s=google header.b=a4JqT1CS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751980AbeEQNb5 (ORCPT + 99 others); Thu, 17 May 2018 09:31:57 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:39511 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751319AbeEQNbz (ORCPT ); Thu, 17 May 2018 09:31:55 -0400 Received: by mail-wm0-f65.google.com with SMTP id f8-v6so9150861wmc.4 for ; Thu, 17 May 2018 06:31:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Nt70djOL729f2pZKM3rM7dXctz/XtZIntF3GoOPvqmc=; b=a4JqT1CSzm2oh7c8g8ahEYfXiIKBmW5KAPKW0hnL5euc0ZjJj5i/GurYNdm1sVMEaw HTsZHo3qUoenFtCmDpNh5c/2pqRBvnDNRYXaL60nJvbEB1IVnY0L+mYro46iWy0jo4ia 3xCxWq+0VZG7G0HcKdPtRlWaB0EgXPRgmJMUQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Nt70djOL729f2pZKM3rM7dXctz/XtZIntF3GoOPvqmc=; b=StNNPM0yn+Z6DUtOy+s2WUso7Rab/CMHe495uoXJYFlChabzZ0yhEg6fHBknHug45h QCUTNp5/DKSNXBrpE/crgYTmEOHCdvDoZLr3cSlVD88pSd//vhuQdteKWzXEN6CogllJ zMDXg/d6UkfSFKFJbw7rWmFK9GuH1cdpWOpF6FJM7gsWoXc7UPPSxxYLKRL0Z4+6dCrD 5MPjsQwUXOIjGA9eKk79KibyppmWmc1q+9HjLuU9SF05IpMT7r2WryAJBEGfH9TNvKan VwVtX20d4R1hAheRLa5ylG5b2zQP1PlSyhJ5zWKU3Z9+Fkb2TXxmwUSACjz3GDuvHO8r R/+g== X-Gm-Message-State: ALKqPwc5oLQLpfHZAYxv1qiJkr1AlrkWPd8QJis9Ke0RB+1Vvq0a+25m e/Qpc5LT6loXsnu4rDx1rjYmU3rAbpc= X-Received: by 2002:a1c:1a53:: with SMTP id a80-v6mr1914163wma.36.1526563914364; Thu, 17 May 2018 06:31:54 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id w6-v6sm5674223wra.16.2018.05.17.06.31.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 May 2018 06:31:53 -0700 (PDT) Date: Thu, 17 May 2018 14:31:51 +0100 From: Daniel Thompson To: Dan Carpenter Cc: Jason Wessel , Arnd Bergmann , Greg Kroah-Hartman , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] misc: kgdbts: silence array underflow warning Message-ID: <20180517133151.tzdkkomabejupex7@holly.lan> References: <20180517122229.GA7655@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180517122229.GA7655@mwanda> User-Agent: NeoMutt/20180512 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 17, 2018 at 03:22:29PM +0300, Dan Carpenter wrote: > Smatch distrusts simple_strtol(). I don't know the code well enough > to say if the distrust is justified here, but it seems harmless to > silence the warning. What warning does this fix? I'd prefer to have it in the description. > Signed-off-by: Dan Carpenter > > diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c > index 6193270e7b3d..e0508acaedaa 100644 > --- a/drivers/misc/kgdbts.c > +++ b/drivers/misc/kgdbts.c > @@ -400,13 +400,15 @@ static void skip_back_repeat_test(char *arg) > int go_back = simple_strtol(arg, NULL, 10); If go_back is out of range then this is a serious error in the test plans found in the module. Something simple and clear such as BUG_ON(go_back <= 0 || go_back > ts.idx) is probably sufficient. > repeat_test--; > - if (repeat_test <= 0) { > + if (repeat_test <= 0 || go_back < 0) { The BUG_ON() will mess things up because whatever breakpoints the test is using are still enabled. If you really want to recover cleanly then perhaps: + if (repeat_test <= 0 || WARN_ON(go_back < 0 || go_back > ts.idx)) { > ts.idx++; > } else { > if (repeat_test % 100 == 0) > v1printk("kgdbts:RUN ... %d remaining\n", repeat_test); > > ts.idx -= go_back; > + if (ts.idx < 0) > + ts.idx = 0; Not sure about this. If we know the opcodes are bad then re-executing them doesn't seem like a good idea (hence covering it in the WARN_ON branch above). Daniel.