All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeedm@mellanox.com>
To: "cai@lca.pw" <cai@lca.pw>
Cc: "linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	"davem@davemloft.net" <davem@davemloft.net>,
	Moshe Shemesh <moshe@mellanox.com>,
	Feras Daoud <ferasda@mellanox.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Eran Ben Elisha <eranbe@mellanox.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"leon@kernel.org" <leon@kernel.org>
Subject: Re: [PATCH] net/mlx5: fix a -Wstringop-truncation warning
Date: Tue, 27 Aug 2019 21:46:58 +0000	[thread overview]
Message-ID: <c1844fb0d81592dfc48f8291f2fdd2a25e1d2e7f.camel@mellanox.com> (raw)
In-Reply-To: <1566936733.5576.16.camel@lca.pw>

On Tue, 2019-08-27 at 16:12 -0400, Qian Cai wrote:
> On Mon, 2019-08-26 at 21:11 +0000, Saeed Mahameed wrote:
> > On Fri, 2019-08-23 at 15:56 -0400, Qian Cai wrote:
> > > In file included from ./arch/powerpc/include/asm/paca.h:15,
> > >                  from ./arch/powerpc/include/asm/current.h:13,
> > >                  from ./include/linux/thread_info.h:21,
> > >                  from ./include/asm-generic/preempt.h:5,
> > >                  from
> > > ./arch/powerpc/include/generated/asm/preempt.h:1,
> > >                  from ./include/linux/preempt.h:78,
> > >                  from ./include/linux/spinlock.h:51,
> > >                  from ./include/linux/wait.h:9,
> > >                  from ./include/linux/completion.h:12,
> > >                  from ./include/linux/mlx5/driver.h:37,
> > >                  from
> > > drivers/net/ethernet/mellanox/mlx5/core/lib/eq.h:6,
> > >                  from
> > > drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c:33:
> > > In function 'strncpy',
> > >     inlined from 'mlx5_fw_tracer_save_trace' at
> > > drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c:549:2,
> > >     inlined from 'mlx5_tracer_print_trace' at
> > > drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c:574:2:
> > > ./include/linux/string.h:305:9: warning: '__builtin_strncpy'
> > > output
> > > may
> > > be truncated copying 256 bytes from a string of length 511
> > > [-Wstringop-truncation]
> > >   return __builtin_strncpy(p, q, size);
> > >          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > 
> > > Fix it by using the new strscpy_pad() since the commit
> > > 458a3bf82df4
> > > ("lib/string: Add strscpy_pad() function") which will always
> > > NUL-terminate the string, and avoid possibly leak data through
> > > the
> > > ring
> > > buffer where non-admin account might enable these events through
> > > perf.
> > > 
> > > Fixes: fd1483fe1f9f ("net/mlx5: Add support for FW reporter
> > > dump")
> > > Signed-off-by: Qian Cai <cai@lca.pw>
> > 
> > Hi Qian and thanks for your patch,
> > 
> > We already have a patch that handles this issue, please check it
> > out:
> > https://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git/commit/?h=net-
> > next-mlx5
> > 
> 
> That commit will make "struct mlx5_fw_tracer" too large and trigger a
> warning in
> __alloc_pages_nodemask(),
> 

I see! thanks for the input, the patch is still under review and not
yet passed to regression queue.

I will take your patch.. and will fix our patch on top of yours.

>         /*
>          * There are several places where we assume that the order
> value is sane
>          * so bail out early if the request is out of bound.
>          */
>         if (unlikely(order >= MAX_ORDER)) {
>                 WARN_ON_ONCE(!(gfp_mask & __GFP_NOWARN));
>                 return NULL;
>         }
> 
> [   98.339576][  T914] WARNING: CPU: 0 PID: 914 at
> mm/page_alloc.c:4705
> __alloc_pages_nodemask+0x441/0x1bb0
> [   98.349174][  T914] Modules linked in: smartpqi(+)
> scsi_transport_sas tg3
> mlx5_core(+) libphy firmware_class dm_mirror dm_region_hash dm_log
> dm_mod
> efivarfs
> [   98.363495][  T914] CPU: 0 PID: 914 Comm: kworker/0:2 Not tainted
> 5.3.0-rc6-
> next-20190827+ #14
> [   98.372243][  T914] Hardware name: HPE ProLiant DL385
> Gen10/ProLiant DL385
> Gen10, BIOS A40 07/10/2019
> [   98.381627][  T914] Workqueue: events work_for_cpu_fn
> [   98.386720][  T914] RIP: 0010:__alloc_pages_nodemask+0x441/0x1bb0
> [   98.392917][  T914] Code: 17 00 00 48 8d 65 d8 5b 41 5c 41 5d 41
> 5e 41 5f 5d
> c3 89 85 3c fe ff ff bb 01 00 00 00 e9 96 fd ff ff 81 e7 00 20 00 00
> 75 02 <0f>
> 0b 48 c7 85 50 fe ff ff 00 00 00 00 eb 82 31 d2 be 36 12 00 00
> [   98.412740][  T914] RSP: 0018:ffff88853418f948 EFLAGS: 00010246
> [   98.418704][  T914] RAX: 0000000000000000 RBX: ffffffff9571a860
> RCX:
> 1ffff110a6831f3e
> [   98.426652][  T914] RDX: 0000000000000000 RSI: 000000000000000b
> RDI:
> 0000000000000000
> [   98.434661][  T914] RBP: ffff88853418fb58 R08: ffffed1108808465
> R09:
> ffffed1108808465
> [   98.442613][  T914] R10: ffffed1108808464 R11: ffff888844042323
> R12:
> 0000000000000000
> [   98.450548][  T914] R13: 000000000000000b R14: 0000000000000000
> R15:
> 0000000000000001
> [   98.458434][  T914] FS:  0000000000000000(0000)
> GS:ffff888844000000(0000)
> knlGS:0000000000000000
> [   98.467350][  T914] CS:  0010 DS: 0000 ES: 0000 CR0:
> 0000000080050033
> [   98.473911][  T914] CR2: 0000555c64680148 CR3: 0000000550412000
> CR4:
> 00000000003406b0
> [   98.481838][  T914] Call Trace:
> [   98.485011][  T914]  ? find_next_bit+0x2c/0xa0
> [   98.489490][  T914]  ? __kasan_check_write+0x14/0x20
> [   98.494506][  T914]  ? graph_lock+0xb8/0x120
> [   98.498811][  T914]  ? __free_zapped_classes+0x740/0x740
> [   98.504239][  T914]  ? gfp_pfmemalloc_allowed+0xc0/0xc0
> [   98.509504][  T914]  ? __kasan_check_read+0x11/0x20
> [   98.514443][  T914]  ? register_lock_class+0x5ef/0x960
> [   98.519624][  T914]  ? rcu_read_lock_sched_held+0xac/0xe0
> [   98.525152][  T914]  ? rcu_read_lock_any_held.part.5+0x20/0x20
> [   98.531130][  T914]  ? find_next_bit+0x2c/0xa0
> [   98.535610][  T914]  alloc_pages_current+0x9c/0x110
> [   98.540638][  T914]  kmalloc_order+0x22/0x70
> [   98.544943][  T914]  kmalloc_order_trace+0x23/0x100
> [   98.550072][  T914]  mlx5_fw_tracer_create+0x51/0x870 [mlx5_core]
> [   98.556213][  T914]  ? __mutex_init+0x94/0xa0
> [   98.560744][  T914]  ? mlx5_init_rl_table+0x144/0x210 [mlx5_core]
> [   98.566929][  T914]  mlx5_load_one+0x199/0x980 [mlx5_core]
> [   98.572637][  T914]  init_one+0x494/0x760 [mlx5_core]
> [   98.577771][  T914]  ? mlx5_pci_resume+0xd0/0xd0 [mlx5_core]
> [   98.583574][  T914]  local_pci_probe+0x7a/0xc0
> [   98.588054][  T914]  ? pci_dma_configure+0xa0/0xa0
> [   98.592938][  T914]  work_for_cpu_fn+0x2e/0x50
> [   98.597416][  T914]  process_one_work+0x53b/0xa70
> [   98.602220][  T914]  ? pwq_dec_nr_in_flight+0x170/0x170
> [   98.607485][  T914]  ? move_linked_works+0x113/0x150
> [   98.612497][  T914]  worker_thread+0x363/0x5b0
> [   98.616976][  T914]  kthread+0x1df/0x200
> [   98.620932][  T914]  ? process_one_work+0xa70/0xa70
> [   98.625847][  T914]  ? kthread_park+0xd0/0xd0
> [   98.630240][  T914]  ret_from_fork+0x22/0x40

  reply	other threads:[~2019-08-27 21:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-23 19:56 [PATCH] net/mlx5: fix a -Wstringop-truncation warning Qian Cai
2019-08-23 22:18 ` David Miller
2019-08-26 20:18   ` Saeed Mahameed
2019-08-26 21:11 ` Saeed Mahameed
2019-08-27 20:12   ` Qian Cai
2019-08-27 21:46     ` Saeed Mahameed [this message]
2019-08-27 21:51 ` Saeed Mahameed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c1844fb0d81592dfc48f8291f2fdd2a25e1d2e7f.camel@mellanox.com \
    --to=saeedm@mellanox.com \
    --cc=cai@lca.pw \
    --cc=davem@davemloft.net \
    --cc=eranbe@mellanox.com \
    --cc=ferasda@mellanox.com \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=moshe@mellanox.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.