Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2039644imm; Thu, 18 Oct 2018 08:09:39 -0700 (PDT) X-Google-Smtp-Source: ACcGV60fSHQgus3DbQFLlARFJL86734F2u2ctU0gpL+GnvMADbt3NZcbAbCB/1bpjn7YLeu6nWDk X-Received: by 2002:a63:1555:: with SMTP id 21-v6mr28567356pgv.383.1539875379928; Thu, 18 Oct 2018 08:09:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539875379; cv=none; d=google.com; s=arc-20160816; b=AQldYimCm2h8v3tD/wcnHkIe3mp3oFJZe3Rk02PhBogB2t0VzlYqEMJlh1mqTvBhXc 4szjeootT2onLLPZKoyW0s16M+WF8ZvRpUavqI9eHW/3u78/59WKlk4FpCwI75MviLGS /EJiTHUGBUJQ3kGD68vmwM0rPUe7alhTGva3+oEJijEC/xjEPvzgh6VxbA5XQCz27QAl 3K2r+Chrb8T5vR8CSRIRiutLUnd5UfGccNA0N3fGXCXKGJxKr/NdWbOBCoYX2a/ORmZ4 LD/D3PykrNNQb2zzJ7VlYao8xAOpYqZF5k7533P/HGV/Ci0ybWEmJpGFN3FQx8O38nxu 0saw== 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:mime-version :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=xSVEuo20v/2OKIqauQYAI1g6OnejAAHkjt/2qMMzOXI=; b=SyGOG0eQTQ6j9W6RNxelKTnTAIuMz2f2Z6iw6QD6rPH1CVTxAoK9QdEIpLTwvtsF1K cDURn3+88VC7gMUqTK8nINoIj90ti5acBoEWmOTF+pxpFvtm6m60HMaoqWwjUXV0sBAk Nj5tMmsL2pbuh1cA8l2KdfGnY2dJj06ugJAQTS+KyFqnbHEPBlFJUO94891oQkhz/I59 CWm4ruVgs2L3KpnGxybl+FulRf2nUxftRAXjRdaxwx71rC9PZ/AtD7cWMSBYPkMrUum/ gyuGJqjDmNOZzs9hR2bQqiZyywyG9mOP4uDfKbk4/sWHq9yuJQKitRRqiCQYyuw+YGX0 /qMw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v20-v6si19500582pgk.586.2018.10.18.08.09.24; Thu, 18 Oct 2018 08:09:39 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727611AbeJRXKE convert rfc822-to-8bit (ORCPT + 99 others); Thu, 18 Oct 2018 19:10:04 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([146.101.78.151]:36523 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726133AbeJRXKE (ORCPT ); Thu, 18 Oct 2018 19:10:04 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-139-J2gqySlWOL6SzHQP0_AXBw-1; Thu, 18 Oct 2018 16:08:32 +0100 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 18 Oct 2018 16:08:34 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Thu, 18 Oct 2018 16:08:34 +0100 From: David Laight To: 'Dan Carpenter' , "kys@microsoft.com" CC: "gregkh@linuxfoundation.org" , "linux-kernel@vger.kernel.org" , "devel@linuxdriverproject.org" , "olaf@aepfle.de" , "apw@canonical.com" , "jasowang@redhat.com" , "sthemmin@microsoft.com" , "Michael.H.Kelley@microsoft.com" , "vkuznets@redhat.com" , Haiyang Zhang Subject: RE: [PATCH V2 5/5] Tools: hv: kvp: Fix a warning of buffer overflow with gcc 8.0.1 Thread-Topic: [PATCH V2 5/5] Tools: hv: kvp: Fix a warning of buffer overflow with gcc 8.0.1 Thread-Index: AQHUZqxsXivxKNXkpUiDU89D21DY1aUlGmNg Date: Thu, 18 Oct 2018 15:08:34 +0000 Message-ID: <872b63db79e5468f97dded249c4478f9@AcuMS.aculab.com> References: <20181018050835.27828-1-kys@linuxonhyperv.com> <20181018050932.27932-1-kys@linuxonhyperv.com> <20181018050932.27932-5-kys@linuxonhyperv.com> <20181018063230.v6hp5e3agk62c3s3@mwanda> In-Reply-To: <20181018063230.v6hp5e3agk62c3s3@mwanda> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-MC-Unique: J2gqySlWOL6SzHQP0_AXBw-1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter > Sent: 18 October 2018 07:33 > > On Thu, Oct 18, 2018 at 05:09:32AM +0000, kys@linuxonhyperv.com wrote: > > From: Dexuan Cui > > > > The patch fixes: > > > > hv_kvp_daemon.c: In function 'kvp_set_ip_info': > > hv_kvp_daemon.c:1305:2: note: 'snprintf' output between 41 and 4136 bytes > > into a destination of size 4096 > > > > The "(unsigned int)str_len" is to avoid: > > > > hv_kvp_daemon.c:1309:30: warning: comparison of integer expressions of > > different signedness: 'int' and 'long unsigned int' [-Wsign-compare] I usually use 'str_len + 0u' rather than a cast. > Ugh... Any tool with the most basic flow analysis would realize this > was a false positive. We use at least three static analyzers which > catch signedness bugs. Can we turn off GCC's warning on this until they > improve it a bit? Yes, would be nice if it attempted to follow the valid domain of variables. I recently had to change: unsigned char a, b; unsigned int c; ... if (a + b < c) To stop a 'signedness' warning. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)