Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp708409imd; Sat, 3 Nov 2018 08:40:34 -0700 (PDT) X-Google-Smtp-Source: AJdET5d9OzkhAB8FdzRmlU1TWJrJftdn2a3FsHHtb5vZmiov/j0obnoj/lpjGxiId57iZZV9PuVU X-Received: by 2002:a63:41c2:: with SMTP id o185-v6mr14366466pga.11.1541259634594; Sat, 03 Nov 2018 08:40:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541259634; cv=none; d=google.com; s=arc-20160816; b=ngyuk+tPZh8QPUqvcZvFAjLjszkB8a7UAwdD07JFcV3osrye7Qs5e3wBhQKOof1xfV Yveb+U4Bn5SjW1g6rQZy1rgJVuJGFInNvuNRA2vKEWQN3PjpXX0zEvdCQFf37inahCI+ +aUKCuKaR4dZ97Ud9qY+rBiIQvgs53+/T1l7i/tB8480OExOd5vT8JopusI2dMzHIQ81 BtVFCon3iUWNeTDhzU4w+SAIKvwlxlOk2N5iqw7hY/xFyTx2QAvmGGjVO72A2OV26T3O JVnkFlaXZWAnLKKQvh5o5fHY1zpQ/XUSjecGXi9sGAY4yHD3rbPDhNPNX7w8UPpqlG6F c8bg== 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; bh=0hqAQLOqFQVsczGvcMDnxjl7eGvdeo9LIpKwvDyrZxc=; b=d9SI+gBFk4BqSWyFxlfoPmk+jUiUzbTgzra0GLByj+KD5q3macTIROil6lIg2NC376 lBFbkPlcCqMY3rdt8Dk7flkjaXg6yd3zOKKliu/Roui+W5AkkPHoAms4xjy87i4wlmlt u3DkBqPNOp2QH38150oqksyChijO8skJnPv85pzlRdJT6uUOdpfSg49inrCrN+ou7QTu Py7mFoS7C/y4P8w2Ts/WsDvt2p4KW6UeIruDeBjoB99/FL6/l3Rcw7tPqINzAIT4QGVb tvuiIxr5N8a2XBeA5hRkzHQZGsuQOwZwsjyKq1EI786flsS8286+xURWMcqmiEsAEU7f Mgnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pvv3YCvY; 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 d4-v6si36635428pgl.524.2018.11.03.08.40.05; Sat, 03 Nov 2018 08:40:34 -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=Pvv3YCvY; 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 S1727801AbeKDAvL (ORCPT + 99 others); Sat, 3 Nov 2018 20:51:11 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:33896 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726387AbeKDAvK (ORCPT ); Sat, 3 Nov 2018 20:51:10 -0400 Received: by mail-ed1-f67.google.com with SMTP id w19-v6so4124482eds.1 for ; Sat, 03 Nov 2018 08:39:31 -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=0hqAQLOqFQVsczGvcMDnxjl7eGvdeo9LIpKwvDyrZxc=; b=Pvv3YCvYeUO7ynri4chCxtnjikLL1Xk7pFZqKUeduvCBYbgyM4QC79LK9O2FWEhSC6 dQz6O7tfy1dIc8+N4hQuAcEfc8whiBCQH5L4vHSQk0Ac05NyO2KSFjy4GULr+llqJGUo FZZO7LL+SnJ6n4ajbsPlIm8qLjFldwbxy+7Dw= 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=0hqAQLOqFQVsczGvcMDnxjl7eGvdeo9LIpKwvDyrZxc=; b=G3RjbkUiyCeFrvQ+AKISDCc/XraF2NszBYbOtsIAGP4cJx1ZHoHIoKK1qYChdgtkNH 1wBDmprGOHozRGRUG0RUrEaHkcww9KsY75LYZyyIENMtJ48f0vgaJhAhYElL9RR1wPFc 2QfjwS1MK8ApzfV/hUNxNI19ku/yVM3fdapl0SdxW1z9LX+AAg/fq20oo1LfcuYgVkZB Xg7yJ3Lr7rTIAw7gnUPOyxAzMfOVpGkZQeQ4TuePOnxe+9ViFCAcha7RHWj0czex6zKm DZJ2oIhYds4IISzboxpwbvqY6Xy6UGqzq1eZJB+ABZKn3JEj8lI0HDSHmthGiOxG+hpf iy6Q== X-Gm-Message-State: AGRZ1gI4Hrf663/hooZCAOE7VxLGaZqLKH38x8m6Z9PCOGhYV74FQ1kO 7GnqSq/mggHuuCwkO+bk7dW6bw== X-Received: by 2002:a50:a938:: with SMTP id l53-v6mr12542299edc.30.1541259570399; Sat, 03 Nov 2018 08:39:30 -0700 (PDT) Received: from holly.lan ([185.80.85.115]) by smtp.gmail.com with ESMTPSA id o8-v6sm1439143edr.68.2018.11.03.08.39.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Nov 2018 08:39:29 -0700 (PDT) Date: Sat, 3 Nov 2018 15:39:25 +0000 From: Daniel Thompson To: Olof Johansson Cc: Jason Wessel , linux-kernel@vger.kernel.org, kgdb-bugreport@lists.sourceforge.net, prarit@redhat.com Subject: Re: [PATCH] kdb: fix strncpy warning Message-ID: <20181103153925.ozyb4pqnixu6hw4z@holly.lan> References: <20181102212405.5911-1-olof@lixom.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181102212405.5911-1-olof@lixom.net> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 02, 2018 at 02:24:05PM -0700, Olof Johansson wrote: > kdb does a strncpy(a, b, strlen(b)+1), which makes no sense. Might as > well do a strcpy at this point. > > Fixes this warning: > > In function 'strncpy', inlined from 'kallsyms_symbol_next' at kernel/debug/kdb/kdb_support.c:239:4: > ./include/linux/string.h:253:9: warning: '__builtin_strncpy' specified bound depends on the length of the source argument [-Wstringop-overflow=] I think we already have a pending patch for this: https://lore.kernel.org/patchwork/patch/989013/ When we looked into this there actually is an unchecked overflow here so Prarit's fix adds infrastructure to keep track of the remaining length. Daniel. > > Signed-off-by: Olof Johansson > --- > kernel/debug/kdb/kdb_support.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/debug/kdb/kdb_support.c b/kernel/debug/kdb/kdb_support.c > index 990b3cc526c8..d5af8b38b84d 100644 > --- a/kernel/debug/kdb/kdb_support.c > +++ b/kernel/debug/kdb/kdb_support.c > @@ -236,7 +236,7 @@ int kallsyms_symbol_next(char *prefix_name, int flag) > > while ((name = kdb_walk_kallsyms(&pos))) { > if (strncmp(name, prefix_name, prefix_len) == 0) { > - strncpy(prefix_name, name, strlen(name)+1); > + strcpy(prefix_name, name); > return 1; > } > } > -- > 2.11.0 >