Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3597099imm; Mon, 13 Aug 2018 14:48:56 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzQiOkEgpfMZax5E/ggYRipdqaVWgQwhZDvTOaD1mpUUCclrM+kObzjqbATOUTncX6v8xh/ X-Received: by 2002:a17:902:8e86:: with SMTP id bg6-v6mr17933489plb.108.1534196936120; Mon, 13 Aug 2018 14:48:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534196936; cv=none; d=google.com; s=arc-20160816; b=iJqGokz9s7p5rx17/oHTof2psM/7enG0P5noJkl0l92yS7vaU64UiOJuNgrPGmRtnw TqusnOwgsP4ucBdklyceVkxE1AeDNFysytIv/CIsWVMrpdW40k1IAfqXj7j2yIutXUCo bbIWbIf9hXR9icmlsDPp+LyUkr/FaTnnFv11CZylQHPbb6JzmHHVorUpBi1BMDcUBW+g uWKbobiKR9Lhgc1CxFVrOfiK63v8d0duBTHrLnaMR3LtBlPtlm4laGBRpEJJULr1+/E5 U/zlrevtrSlwyTln0gI/oKKnhuBkdOcW7jcNyYM4UpBStWFgmn93DSqTKrTU8apcJZDG e7Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=2P0RwmOqoSTgFF12VsYF4fhPiPt2ayTCfTvFliwooFE=; b=YsGfXo4h0a+a63gZST/6st31zGc2hN0XRxZuNbzGG/SSP9FPMhpOl3/1bDqUOb/1Rd gRsRERedGzrE1ofch8Az1Bv+czSKPwIBclouk3udTiudjF0Yw+GQr4QK62aR0t3Wg8lr xz3ZsB8kS/09SaRZ1lizImvo/D8IMJmwUWYT6x4UZEVP1iRMnf47umRedyjV23i1wqtw xjXD/uEH/BEkGn+R4b01TJRDEf6UCgWEwgT4/veu+iwNk+IHksGl0T/aDKoCYp06K7ks gHKZMi3PSU7TS/jgOjnPmAxPGWLmNiYihyAS2QeRJkUYe7z0cRZT1HfNgMPFuJSZg/fW QPZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=Cx4KA3kB; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w25-v6si19567443pga.58.2018.08.13.14.48.40; Mon, 13 Aug 2018 14:48:56 -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=@broadcom.com header.s=google header.b=Cx4KA3kB; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730796AbeHNAbz (ORCPT + 99 others); Mon, 13 Aug 2018 20:31:55 -0400 Received: from mail-yw1-f67.google.com ([209.85.161.67]:33674 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730027AbeHNAby (ORCPT ); Mon, 13 Aug 2018 20:31:54 -0400 Received: by mail-yw1-f67.google.com with SMTP id c135-v6so14758396ywa.0 for ; Mon, 13 Aug 2018 14:47:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=2P0RwmOqoSTgFF12VsYF4fhPiPt2ayTCfTvFliwooFE=; b=Cx4KA3kBF7c1ThLa/UauR64e/5+gDPiUN12PunJfMjzosGnSfTIaV1vq5vzjuoTgHP Rm90h8QajVUTyb//uNSOASfG4tY2gSV9a2TH3dZCP1anMr1Ex2hGemDg63dBQAZs0Tzy fALFY+vzGpBwxYPYbmmNngcUEes4GFA6J5Seo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=2P0RwmOqoSTgFF12VsYF4fhPiPt2ayTCfTvFliwooFE=; b=beECXnH/X1gORV+f7TZirY0qsfNHOq2/tJEq0w4gWWBwuxuWVit4Irnp0GIOZCjh2V L2pRNspY4Pok8H8Y0yImOE5UpwP9WfWpIKkQR1d5To0G/KEPrk4L8BerfyYp0W+64JAM l4ACtKmcfHb5Q9g0CAY3nOujml+wjQjaRCghB6Vm+EkeaswWVcrljzjUGdBqluAnAxDp 8lZ8D0EkCgesHuSLXbCvJoeOApte3+XJv/BsQanGGU4/PJoW2p5GlLef50RM4eIqd/Dg 0KFdLE1DI5S1isDi1tR57J86pJZkyILdbsUmDum8qvKsEftnukSQzIpWU4fWLCvw+wIg K7Jg== X-Gm-Message-State: AOUpUlE3i4Bszr1Wp3CcAIQ5+pbxCQItdz0p9ZCcQjDTiOFulVFzn44K CHcn8hghQiqs+9mfhxMA0fOUZjrZM1WxHkRQoaSpdQ== X-Received: by 2002:a25:cf51:: with SMTP id f78-v6mr3343123ybg.496.1534196871215; Mon, 13 Aug 2018 14:47:51 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:e716:0:0:0:0:0 with HTTP; Mon, 13 Aug 2018 14:47:50 -0700 (PDT) In-Reply-To: <20180813212700.2681499-1-arnd@arndb.de> References: <20180813212700.2681499-1-arnd@arndb.de> From: Michael Chan Date: Mon, 13 Aug 2018 14:47:50 -0700 Message-ID: Subject: Re: [PATCH] bnxt_en: avoid string overflow for record->system_name To: Arnd Bergmann Cc: "David S. Miller" , Vasundhara Volam , Scott Branden , Andy Gospodarek , Netdev , open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 13, 2018 at 2:26 PM, Arnd Bergmann wrote: > The utsname()->nodename string may be 64 bytes long, and it gets > copied without the trailing nul byte into the shorter record->system_name, > as gcc now warns: > > In file included from include/linux/bitmap.h:9, > from include/linux/ethtool.h:16, > from drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c:13: > In function 'strncpy', > inlined from 'bnxt_fill_coredump_record' at drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c:2863:2: > include/linux/string.h:254:9: error: '__builtin_strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation] > > Using strlcpy() at least avoids overflowing the destination buffer > and adds proper nul-termination. It may still truncate long names > though, which probably can't be solved here. > > Fixes: 6c5657d085ae ("bnxt_en: Add support for ethtool get dump.") > Signed-off-by: Arnd Bergmann Thanks. Acked-by: Michael Chan