Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5238121ybl; Tue, 27 Aug 2019 01:20:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxzLImJVH5F84muMvg36AsRkyLrXezHZHxfl7ILpr4XdbVsM4c9CX9PPulBSb99EYhI3+Gh X-Received: by 2002:a17:902:8d95:: with SMTP id v21mr7822161plo.267.1566894021243; Tue, 27 Aug 2019 01:20:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566894021; cv=none; d=google.com; s=arc-20160816; b=xjqQEvHl14J2PONJAPvkBJRTHzFfegntA/KMFgFc/m7snug6e9C2aZTwHBrlFVDY/5 ERf6cbxgwG66ysxKQKRrgk8SFpxV7jKwLF5aJkx6etJfYae/3m5UkCLya7I50F4uYXpa KQFZw0rEl+A08CGNZ4htpK97BpKJhBzPD3mtBKx9xyqMcr9ycVlMzQxjMPi0NbKsccha zc2rr1PRahD0FI2tOY+5sIzRayyRlkZFzP5Udnd0AFEK4QwyCirp6vbbr2r+qqpbehyf zyDDceIFGqAmioMZ3XbBmWtEy0JxXVnzDTCuqIPt9sFf3gE0qMYqIhRT8cSOpZyM0+Wr YidQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mMjzqJ7CviJWdUi9HiqzUbEuIBV+BRsPfeUFRn/E2Lg=; b=YRk033OW3ZbOkQg8wBWOlOz3hfL+x8AFB6i1nsY0IlBGXFQN2c/M7CuhJNKHinUFBy qUai8dIAL6n+7Pn/rye759ZWE3S8F567LFCQWDeQJ9wnY6Mb/SvYV1BcJGRIilR71ssn SrvcvF/0hYLZUDVzGS4z8TASfA0pDrqGNkS7jV35OkrNKcZHjTRNsMitGgMh4AN6hLjN CgM2JHJN+H6BgShWs12kRRCCXIGMaFYdZ3L6JYnsoyYVJfVUYb/wmCgtfEdRFeFeWhMB VCP7uYo2jYo34LeCPH90MCW0ukCFBLOF2YnYRJcnShWNH9gmqU9/2W+aojv/VNvChT4R p/lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=igtAVhct; 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 f23si748400plj.241.2019.08.27.01.20.06; Tue, 27 Aug 2019 01:20:21 -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=@kernel.org header.s=default header.b=igtAVhct; 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 S1729393AbfH0HwU (ORCPT + 99 others); Tue, 27 Aug 2019 03:52:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:43510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729353AbfH0HwO (ORCPT ); Tue, 27 Aug 2019 03:52:14 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 86D7D22CF4; Tue, 27 Aug 2019 07:52:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566892333; bh=V++gE4PvWJuMkpFtwQmcf/K7K1tPmJWBBFBe94xTzPo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=igtAVhctzmTl0EZbPSIyT6kyxpByCfKkcd19GRy/gsyXFpklSS2brbD1egCEo6G9g YntM3G218vix6wEIvrl09aUFj47pIHNGsQDLJQRXt91t4wUp9O2r8+q6aLaCRoRJHp fFRPk4xcb9XC77Ka6i0cb0dwT4gqxY624luEBhFU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wang Xiayang , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 20/62] net/ethernet/qlogic/qed: force the string buffer NULL-terminated Date: Tue, 27 Aug 2019 09:50:25 +0200 Message-Id: <20190827072701.496921144@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827072659.803647352@linuxfoundation.org> References: <20190827072659.803647352@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 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 [ Upstream commit 3690c8c9a8edff0db077a38783112d8fe12a7dd2 ] strncpy() does not ensure NULL-termination when the input string size equals to the destination buffer size 30. The output string is passed to qed_int_deassertion_aeu_bit() which calls DP_INFO() and relies NULL-termination. Use strlcpy instead. The other conditional branch above strncpy() needs no fix as snprintf() ensures NULL-termination. This issue is identified by a Coccinelle script. Signed-off-by: Wang Xiayang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/qlogic/qed/qed_int.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/qlogic/qed/qed_int.c b/drivers/net/ethernet/qlogic/qed/qed_int.c index 7746417130bd7..c5d9f290ec4c7 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_int.c +++ b/drivers/net/ethernet/qlogic/qed/qed_int.c @@ -939,7 +939,7 @@ static int qed_int_deassertion(struct qed_hwfn *p_hwfn, snprintf(bit_name, 30, p_aeu->bit_name, num); else - strncpy(bit_name, + strlcpy(bit_name, p_aeu->bit_name, 30); /* We now need to pass bitmask in its -- 2.20.1