Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1115226imm; Wed, 1 Aug 2018 10:25:46 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfm9KWD6+Q0TAqNEVd1Y3Xp+hd90gsJlINzFXvtUTxHGrn2nmK2DXLTAYjrUOUZWkuMLs4s X-Received: by 2002:a17:902:925:: with SMTP id 34-v6mr25944777plm.103.1533144346179; Wed, 01 Aug 2018 10:25:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533144346; cv=none; d=google.com; s=arc-20160816; b=S5imdmvQrp388ghuAZ1dmapCDjrZEJ80lwknkWt+laRkbOPw0Xj2JEfvZj9LAjJlNs 8A+SSqMj2lLaF+Iw4hLUMEwjxGdo187v2mzPm6Y9e8sxNHzLp4fNdg9u9VVqxkce31+7 cpnFU1z/DLwj9VHXjZtNIqJlgvS0UcyTQqLx0NWhZOxdU9yNOtihZhX+m8oITuDzokr+ jYAdQYQ1OxvBqpE2mgPZsKjA53WNoNZ2Be40kqPJbN4A4Mese9XGdH0i10UcnADNXcsf 177RyQf0W4bEeMFrwziZvOe1OU+MTiTpvG8ushEhZQfu/wPZtHdIW8dMBZu3f9HKo11b sZJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=a4nA9B2f91HuefuUfhtzM2OHZixU9cKx+3IgrUfnn74=; b=bO3dWB1RHiCHR2RkvojEbaZubkTDkdOxWyneherfsRW1pJayQ0dlK2IHEXLjd4STcb 7tkaS8TQ9TZnAeDeUK6k0TrkiCuNNPzOx2wm37emzOPVMV7jY9XVpOnl454xQDHEWIOj cB9dcZIkezoeHVexd7lT/FG0lszte3Pcet59ZtmBKKUVdr0vgywoqoPZSWokvGQMAqpz oMgEH7aHWgntXIfYsav6EtYWncWlc/XGKS/UdBLCZh6PM5Q657IqmB7sABxbmaWklraI F3b61VgoLzu+ZYnRmQstBFR62WTp6x3UEW0yv9maH7XnEh86jwWiOrGXHT0ptjGa8utj 2BZA== 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 m70-v6si19468848pfa.45.2018.08.01.10.25.31; Wed, 01 Aug 2018 10:25:46 -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 S2405547AbeHATKW (ORCPT + 99 others); Wed, 1 Aug 2018 15:10:22 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50984 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390435AbeHATKW (ORCPT ); Wed, 1 Aug 2018 15:10:22 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 34597D2F; Wed, 1 Aug 2018 17:23:39 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Douglas Anderson , Sasha Levin Subject: [PATCH 4.14 196/246] serial: core: Make sure compiler barfs for 16-byte earlycon names Date: Wed, 1 Aug 2018 18:51:46 +0200 Message-Id: <20180801165021.108811849@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Douglas Anderson [ Upstream commit c1c734cb1f54b062f7e67ffc9656d82f5b412b9c ] As part of bringup I ended up wanting to call an earlycon driver by a name that was exactly 16-bytes big, specifically "qcom_geni_serial". Unfortunately, when I tried this I found that things compiled just fine. They just didn't work. Specifically the compiler felt perfectly justified in initting the ".name" field of "struct earlycon_id" with the full 16-bytes and just skipping the '\0'. Needless to say, that behavior didn't seem ideal, but I guess someone must have allowed it for a reason. One way to fix this is to shorten the name field to 15 bytes and then add an extra byte after that nobody touches. This should always be initted to 0 and we're golden. There are, of course, other ways to fix this too. We could audit all the users of the "name" field and make them stop at both null termination or at 16 bytes. We could also just make the name field much bigger so that we're not likely to run into this. ...but both seem like we'll just hit the bug again. Signed-off-by: Douglas Anderson Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- include/linux/serial_core.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -348,7 +348,8 @@ struct earlycon_device { }; struct earlycon_id { - char name[16]; + char name[15]; + char name_term; /* In case compiler didn't '\0' term name */ char compatible[128]; int (*setup)(struct earlycon_device *, const char *options); };