Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1337574imm; Tue, 2 Oct 2018 06:45:00 -0700 (PDT) X-Google-Smtp-Source: ACcGV61PAToeK4AsSYkN2fPVUqiY4t12Y/BuLtEiwiebQWVg+0XFuHHFmVUD1Rjx1V2IfzfXvgvC X-Received: by 2002:a63:ef53:: with SMTP id c19-v6mr13456613pgk.386.1538487900053; Tue, 02 Oct 2018 06:45:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538487900; cv=none; d=google.com; s=arc-20160816; b=W/pQYJgoPCRi2ItT/vvB0qUrw5Rjusz7TxKrcyDhc6FjrZvnv+ATss8HD5PvBRa8oy kqDcZDO62eEXmn87+M2f1AA1RSfnF6dFDACUpOZQSJca9p1f1O/Fj0OkdvbUOEJRzhnA EHTU4UTtowBXyFiWPGf9y5wNL3WRIaYygNoSwKJWedcOtfxYyDvbwBVeFXUj155rEgNx I86LjqSoRO3Rmz66t+noBNdtDd8eT18jqBDVO1PtM7ifzwNDSmbPj4FkOpZuPQUpriJS G77Q54fC8oHlgq07Mc2CsHOJGYLZCYsx+UN/2+N24YDB3q4KxioEPrz6MF6SlS7VWS+R Lb4A== 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; bh=SHGBj6d9KvYwwPQEjrY0c/sMSvxojXrlwILnyfluzJs=; b=awoqDphME3CUA2sSV+vqq3q4q7JSiOhzjGken7HIUyio3cCtnJdhl0WRM/J2naPCo2 OG/9FOLfOno1VEhtQlZc402vbzEOv4yeEFgIBJboXVlyxlGm/+ESsMyQrwKDUCEWS8d8 My4Brzl8V02YVvI1FlQxh9WdrL1tDYi5c0/sl99sTr3IgODyF5M3MoLxAWOKeYdiedvH tlnTjqLabL+zzCV8RBScuCWZECEDG2hBB+PlHjuUhmuAw96drjr0JQ26xWK5jd7pHF9d PbnpsGVKB0pS6cGj6HfBUs16PBqRW8QyeNvceougEw92qw09CdSt2hLrkwbDfBiRRHA7 Cpvg== ARC-Authentication-Results: i=1; mx.google.com; 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 t8-v6si5365176pgj.212.2018.10.02.06.44.45; Tue, 02 Oct 2018 06:45:00 -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; 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 S1732936AbeJBUTW (ORCPT + 99 others); Tue, 2 Oct 2018 16:19:22 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35904 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731920AbeJBUTT (ORCPT ); Tue, 2 Oct 2018 16:19:19 -0400 Received: from localhost (24-104-73-23-ip-static.hfc.comcastbusiness.net [24.104.73.23]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id BEDC1C3F; Tue, 2 Oct 2018 13:35:54 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Martin Schwidefsky , Sasha Levin Subject: [PATCH 4.9 28/94] s390/extmem: fix gcc 8 stringop-overflow warning Date: Tue, 2 Oct 2018 06:24:42 -0700 Message-Id: <20181002132502.446676485@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181002132500.494838053@linuxfoundation.org> References: <20181002132500.494838053@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vasily Gorbik [ Upstream commit 6b2ddf33baec23dace85bd647e3fc4ac070963e8 ] arch/s390/mm/extmem.c: In function '__segment_load': arch/s390/mm/extmem.c:436:2: warning: 'strncat' specified bound 7 equals source length [-Wstringop-overflow=] strncat(seg->res_name, " (DCSS)", 7); What gcc complains about here is the misuse of strncat function, which in this case does not limit a number of bytes taken from "src", so it is in the end the same as strcat(seg->res_name, " (DCSS)"); Keeping in mind that a res_name is 15 bytes, strncat in this case would overflow the buffer and write 0 into alignment byte between the fields in the struct. To avoid that increasing res_name size to 16, and reusing strlcat. Reviewed-by: Heiko Carstens Signed-off-by: Vasily Gorbik Signed-off-by: Martin Schwidefsky Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/s390/mm/extmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/s390/mm/extmem.c +++ b/arch/s390/mm/extmem.c @@ -79,7 +79,7 @@ struct qin64 { struct dcss_segment { struct list_head list; char dcss_name[8]; - char res_name[15]; + char res_name[16]; unsigned long start_addr; unsigned long end; atomic_t ref_count; @@ -432,7 +432,7 @@ __segment_load (char *name, int do_nonsh memcpy(&seg->res_name, seg->dcss_name, 8); EBCASC(seg->res_name, 8); seg->res_name[8] = '\0'; - strncat(seg->res_name, " (DCSS)", 7); + strlcat(seg->res_name, " (DCSS)", sizeof(seg->res_name)); seg->res->name = seg->res_name; rc = seg->vm_segtype; if (rc == SEG_TYPE_SC ||