From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81C16C4725D for ; Fri, 19 Jan 2024 07:44:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 713C46B006E; Fri, 19 Jan 2024 02:44:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C3376B0078; Fri, 19 Jan 2024 02:44:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B1866B0075; Fri, 19 Jan 2024 02:44:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 483CF6B0078 for ; Fri, 19 Jan 2024 02:44:48 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 111ACA1D3B for ; Fri, 19 Jan 2024 07:44:48 +0000 (UTC) X-FDA: 81695273856.17.CA2666E Received: from out-181.mta1.migadu.com (out-181.mta1.migadu.com [95.215.58.181]) by imf20.hostedemail.com (Postfix) with ESMTP id EF8E91C0008 for ; Fri, 19 Jan 2024 07:44:45 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="nBww+/xI"; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf20.hostedemail.com: domain of yanjun.zhu@linux.dev designates 95.215.58.181 as permitted sender) smtp.mailfrom=yanjun.zhu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705650286; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=NfdbWh15m6eGg8EbFU7d9Mus+SMsi4OG6VHA3hHpJRY=; b=a/zHTFD+Iob1I6Nv4yzi5bS5Dv1qVfaXogXCSd4GYXU7ipW58IlMs61LSSOoCGLGBN4GNs 7po1HxbcTSTi9ZNGqyBMc+E8Ml65696xxnHzqzElQx+9BgeW6+mrl6249OtjotMJA9m5xj GucmdqiOs2we7ufZIR1X1D3xqhWhpz0= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="nBww+/xI"; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf20.hostedemail.com: domain of yanjun.zhu@linux.dev designates 95.215.58.181 as permitted sender) smtp.mailfrom=yanjun.zhu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705650286; a=rsa-sha256; cv=none; b=XfEc1gEwlKtmMkQBmoWA3L1MqlIpsXZeV60k+ZCbjLHZLVZfz5Dyfc2LrLOppsSsiCqSRr GXYLzUbc3jL4b+AIvgvffiPkHjd0oEXe5MrG+WfDhmI2R5waOOQ23bBFZmPRpPyL9IIPN0 UXExupaw++WG4nFGlV9hvoNMStlzJVY= Message-ID: <7f334083-afab-4393-97d5-7d5fdfab2991@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1705650283; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NfdbWh15m6eGg8EbFU7d9Mus+SMsi4OG6VHA3hHpJRY=; b=nBww+/xICupSH571ZfuSPoZCOk49z5yEvhug1esLrDXCgGSEHixCaP7eaAFT7SdROWovc/ Bf4uh7/hGLC+EwUjon/nz2tzunFdU65M8vRvK2A1FIfGrWwcE23Hzs1kUBb1y/rZ0a5IcQ FQPKjrojPDHRgOfbQZ7Gix3cFmuc3Bo= Date: Fri, 19 Jan 2024 15:44:35 +0800 MIME-Version: 1.0 Subject: Re: [linux-next:master 13015/13783] drivers/net/virtio_net.c:4340:35: error: '%u' directive writing between 1 and 10 bytes into a region of size 9 To: kernel test robot Cc: oe-kbuild-all@lists.linux.dev, Linux Memory Management List , Jakub Kicinski , Xuan Zhuo References: <202401190425.IGYMqCJW-lkp@intel.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Zhu Yanjun In-Reply-To: <202401190425.IGYMqCJW-lkp@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Stat-Signature: 9gyyz1w69de443jh9r9yeznkus3weqex X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: EF8E91C0008 X-HE-Tag: 1705650285-871564 X-HE-Meta: U2FsdGVkX18sXagPqn2QvcWlutG/ecFBVKztbsKLfv6v6PmjS76+6p2xaitWya4D/8q1bnfiq2Jvbr+9d2eRdyXOzGVscQVLXM7hdXKN9eXkAqapLcGKnQCTqDpV0n0Q4vx7DgFiQxbWuMH601Uy7IYXib0AoRdazE5k2ViEQ+/29N5osVBKOB5qh4SzkOJ1U1eEOqG3BFUKbVyCiOqb7bCiZbJBj97Tbr/YUKY+W1sOz4OLOj6HQG5+3e31lt+S5XK5W30GGi0KHDjO9t9CJJ+Ij8dI7D8nPJWH1KSapgejpGgG3lHkYL5gwnITKO7pJ06yHV78lwN7gNrkaR1oiV6Z5Hkvdc5OhVGGEjmU02u47631CLc5ggCZl6NG3fy+WOyxwlvaXHxXqm6fXyXOWHbWxbt2ImKdu2RORGg/JyHLp4CfCpp5AsaoBQ/ZnHPpLJLD1lY0uQh4/tvXuTUi7eBDSQ7s0xGExG3b2IytcNBudDNPcp7SrL4XNh4+lf+5Dj3nhdE4IMynRa9536PPb/ZQt4tB7/djURE8l6sN+ci3UuZgyG2/2D7HTRaRn15H6y1fqAJAhDlNQ7YTf8Tg70BpoBUQDD+oeZM1Sh0QYTONTmQWAVrfePKqkqpQPAHLrdyRza6BlZ/c24QwNmabB+RqDze8aNmdQDHAtG1sc55zkbznh8q6ellA+SWOWe3uYuOX9HY745CP4yNZBpsWBTybFH6xCfntQinITlIwuD8XgkA3KXcq/EpvsJ6CxWh5ArwGV8CZkxhAuP82zXI/yskBsenDM1FfvNu4QbW+NUBai8XJnMeVkXQlbY8Y1inmidjrsjI619vv341vRUGqwgSVuzDJZu7ImpqDGKKrgW6ltbuI+uL2J1/SLt0GF3sRwOi84uABAvo9NwKQ6J7QEpD08XXMH4VslB7O/2g+tgtaCgYQYACuO87DgK3OWX34yWs9cU32dmjUzHhWAat Vn+JwNpp t11LZEXayPYBQq5NJvoXT8MEGHNfHLQVokxwLTQkF/ToTXSYBiSfZ5FJTdYroBJaU1GdNkG/dUM88BfPPkHu8GJdBovYwgRjcr6Ne6LqX8pqxkGHB1ei+BHXHNMdTGuFeHlels3LhxurZ9ix7rL0bzrkodpP7rnBsB0+IezcXOAdGeMU3pdahOt/uPL0bc9oG1uWVzdQ3D7XBnKmGlIQAn41vkcnWqZtUQSs5ZWP8VA9enC8xv4L3E6NQ2g3S5OA+6kqn1kdrwgrSrUEdvNVbACpAWw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 在 2024/1/19 4:36, kernel test robot 写道: > tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master > head: 2863b714f3ad0a9686f2de1b779228ad8c7a8052 > commit: e3fe8d28c67bf6c291e920c6d04fa22afa14e6e4 [13015/13783] virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings > config: x86_64-sof-customedconfig-avs-defconfig (https://download.01.org/0day-ci/archive/20240119/202401190425.IGYMqCJW-lkp@intel.com/config) > compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0 I can reproduce this problem in my local host. It seems that this problem is related with gcc-7. In the same test environment, with gcc-7, this problem will occur. With gcc later than version 9, this problem will not occur. And with u16, the range of %u should be [0, 65535]. Not the following: "    drivers/net/virtio_net.c:4141:27: note: directive argument in the range [0, 2147483647]       sprintf(vi->sq[i].name, "output.%u", i); " And the size of name is 16. That is, the name string can contain 15 bytes characters. When the variable i is set to the maximum 65535, the string should be "output.65535". The size of the string is 12 + 1 = 13 bytes. The size of the name is greater than the maximum string "output.65535". In short, from the above, this problem results from gcc-7. It is a problem with gcc-7. Based on my tests with gcc-9, gcc-13, this problem is fixed in later gcc versions. And the warning is a false warning to this commit. Best Regards Zhu Yanjun > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240119/202401190425.IGYMqCJW-lkp@intel.com/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot > | Closes: https://lore.kernel.org/oe-kbuild-all/202401190425.IGYMqCJW-lkp@intel.com/ > > All errors (new ones prefixed by >>): > > drivers/net/virtio_net.c: In function 'init_vqs': > drivers/net/virtio_net.c:4339:36: error: 'sprintf' may write a terminating nul past the end of the destination [-Werror=format-overflow=] > sprintf(vi->rq[i].name, "input.%u", i); > ^ > drivers/net/virtio_net.c:4339:3: note: 'sprintf' output between 8 and 17 bytes into a destination of size 16 > sprintf(vi->rq[i].name, "input.%u", i); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> drivers/net/virtio_net.c:4340:35: error: '%u' directive writing between 1 and 10 bytes into a region of size 9 [-Werror=format-overflow=] > sprintf(vi->sq[i].name, "output.%u", i); > ^~ > drivers/net/virtio_net.c:4340:27: note: directive argument in the range [0, 2147483647] > sprintf(vi->sq[i].name, "output.%u", i); > ^~~~~~~~~~~ > drivers/net/virtio_net.c:4340:3: note: 'sprintf' output between 9 and 18 bytes into a destination of size 16 > sprintf(vi->sq[i].name, "output.%u", i); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > cc1: all warnings being treated as errors > > > vim +4340 drivers/net/virtio_net.c > > 4293 > 4294 static int virtnet_find_vqs(struct virtnet_info *vi) > 4295 { > 4296 vq_callback_t **callbacks; > 4297 struct virtqueue **vqs; > 4298 const char **names; > 4299 int ret = -ENOMEM; > 4300 int total_vqs; > 4301 bool *ctx; > 4302 u16 i; > 4303 > 4304 /* We expect 1 RX virtqueue followed by 1 TX virtqueue, followed by > 4305 * possible N-1 RX/TX queue pairs used in multiqueue mode, followed by > 4306 * possible control vq. > 4307 */ > 4308 total_vqs = vi->max_queue_pairs * 2 + > 4309 virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ); > 4310 > 4311 /* Allocate space for find_vqs parameters */ > 4312 vqs = kcalloc(total_vqs, sizeof(*vqs), GFP_KERNEL); > 4313 if (!vqs) > 4314 goto err_vq; > 4315 callbacks = kmalloc_array(total_vqs, sizeof(*callbacks), GFP_KERNEL); > 4316 if (!callbacks) > 4317 goto err_callback; > 4318 names = kmalloc_array(total_vqs, sizeof(*names), GFP_KERNEL); > 4319 if (!names) > 4320 goto err_names; > 4321 if (!vi->big_packets || vi->mergeable_rx_bufs) { > 4322 ctx = kcalloc(total_vqs, sizeof(*ctx), GFP_KERNEL); > 4323 if (!ctx) > 4324 goto err_ctx; > 4325 } else { > 4326 ctx = NULL; > 4327 } > 4328 > 4329 /* Parameters for control virtqueue, if any */ > 4330 if (vi->has_cvq) { > 4331 callbacks[total_vqs - 1] = NULL; > 4332 names[total_vqs - 1] = "control"; > 4333 } > 4334 > 4335 /* Allocate/initialize parameters for send/receive virtqueues */ > 4336 for (i = 0; i < vi->max_queue_pairs; i++) { > 4337 callbacks[rxq2vq(i)] = skb_recv_done; > 4338 callbacks[txq2vq(i)] = skb_xmit_done; > 4339 sprintf(vi->rq[i].name, "input.%u", i); >> 4340 sprintf(vi->sq[i].name, "output.%u", i); > 4341 names[rxq2vq(i)] = vi->rq[i].name; > 4342 names[txq2vq(i)] = vi->sq[i].name; > 4343 if (ctx) > 4344 ctx[rxq2vq(i)] = true; > 4345 } > 4346 > 4347 ret = virtio_find_vqs_ctx(vi->vdev, total_vqs, vqs, callbacks, > 4348 names, ctx, NULL); > 4349 if (ret) > 4350 goto err_find; > 4351 > 4352 if (vi->has_cvq) { > 4353 vi->cvq = vqs[total_vqs - 1]; > 4354 if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VLAN)) > 4355 vi->dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; > 4356 } > 4357 > 4358 for (i = 0; i < vi->max_queue_pairs; i++) { > 4359 vi->rq[i].vq = vqs[rxq2vq(i)]; > 4360 vi->rq[i].min_buf_len = mergeable_min_buf_len(vi, vi->rq[i].vq); > 4361 vi->sq[i].vq = vqs[txq2vq(i)]; > 4362 } > 4363 > 4364 /* run here: ret == 0. */ > 4365 > 4366 > 4367 err_find: > 4368 kfree(ctx); > 4369 err_ctx: > 4370 kfree(names); > 4371 err_names: > 4372 kfree(callbacks); > 4373 err_callback: > 4374 kfree(vqs); > 4375 err_vq: > 4376 return ret; > 4377 } > 4378 >