Received: by 10.192.165.148 with SMTP id m20csp4168387imm; Mon, 30 Apr 2018 13:04:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZocrGJ8VBWJx5hsRZYtR/wDVdphNODFgyw6LWOYB+uJXEAv/rO7UAmwbuObM/VmgBjptI2C X-Received: by 10.98.82.131 with SMTP id g125mr13137730pfb.198.1525118686246; Mon, 30 Apr 2018 13:04:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525118686; cv=none; d=google.com; s=arc-20160816; b=LhcbndnyP3Pc25oIJ7smaEcQJupnDgoIqCgGKVd7x4m3P5DmsiTlPGwMo0pSi92Upx S7NRAGUrD5J0xuMHj9YU2rKF9fYpCkMghy2ibAT/GRMVpmzodxGBoxw60BSdILvHzf6b B/6kyZqTtMcmFNpoLp3dJlxBE8iKoS7IohMXQn5nngUPEEBhtWIcWxDnreKaixLMFB7q DDgRVzfyo/JXDy8L4gRH/Gou94KRgq2uhHWC5Bwegp/SXTMXvUvA84r5SuZkkwVXSNUg T4pikMOcmRdayqUvjXKkYWjLFqspElPcFuXEM0kqmJ5SW2rd0/XHCqthb9a55xes/TF5 D92w== 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:dmarc-filter :arc-authentication-results; bh=BKh7Ir1/RlNzX4r9lKuHZTU9m4ccm2bEi2PNbj59Vq8=; b=mq88CgzOerXy8QstRB9kUWperGD2nNKzTfqkclcQZpY9t5a7cTKymgjJAw6kcuSlvF 3RhDADuBDxj3GnjFKbUZ/HG1G4nBtAYEB3yXMotjL/yal7VBnl53+fKUedsfVhpZ9pDF qkURSXANfQXJtx17KHujex/rBXy9VoKhGiO3jPYDfNOcbIF7e41L87srfZMEv4mgJDqt xS3+hutEswQbQx1FYJ+L1uTdh3GRAmrFatuvoGggdWZerY24nKW+Oy5lYHDGrti8vN5W k81dCJUuOiSOmE9i0S599QO64e+vD8Lr0NDyBvUqzFIDi7abNjGJ0QXRVObmwMuX9+JG ZICA== 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 r4si8022036pff.24.2018.04.30.13.04.32; Mon, 30 Apr 2018 13:04: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 S1756078AbeD3UEI (ORCPT + 99 others); Mon, 30 Apr 2018 16:04:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:34216 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755341AbeD3T1d (ORCPT ); Mon, 30 Apr 2018 15:27:33 -0400 Received: from localhost (unknown [104.132.1.102]) (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 D359522DCB; Mon, 30 Apr 2018 19:27:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D359522DCB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tetsuo Handa , syzbot , Michal Hocko , Vegard Nossum , Dmitry Vyukov , Jiri Slaby , Peter Hurley , One Thousand Gnomes , Linus Torvalds Subject: [PATCH 4.14 33/91] tty: Use __GFP_NOFAIL for tty_ldisc_get() Date: Mon, 30 Apr 2018 12:24:15 -0700 Message-Id: <20180430184005.898132642@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184004.216234025@linuxfoundation.org> References: <20180430184004.216234025@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: Tetsuo Handa commit bcdd0ca8cb8730573afebcaae4138f8f4c8eaa20 upstream. syzbot is reporting crashes triggered by memory allocation fault injection at tty_ldisc_get() [1]. As an attempt to handle OOM in a graceful way, we have tried commit 5362544bebe85071 ("tty: don't panic on OOM in tty_set_ldisc()"). But we reverted that attempt by commit a8983d01f9b7d600 ("Revert "tty: don't panic on OOM in tty_set_ldisc()"") due to reproducible crash. We should spend resource for finding and fixing race condition bugs rather than complicate error paths for 2 * sizeof(void *) bytes allocation failure. [1] https://syzkaller.appspot.com/bug?id=489d33fa386453859ead58ff5171d43772b13aa3 Signed-off-by: Tetsuo Handa Reported-by: syzbot Cc: Michal Hocko Cc: Vegard Nossum Cc: Dmitry Vyukov Cc: Jiri Slaby Cc: Peter Hurley Cc: One Thousand Gnomes Cc: Linus Torvalds Cc: stable Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/tty/tty_ldisc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) --- a/drivers/tty/tty_ldisc.c +++ b/drivers/tty/tty_ldisc.c @@ -175,12 +175,11 @@ static struct tty_ldisc *tty_ldisc_get(s return ERR_CAST(ldops); } - ld = kmalloc(sizeof(struct tty_ldisc), GFP_KERNEL); - if (ld == NULL) { - put_ldops(ldops); - return ERR_PTR(-ENOMEM); - } - + /* + * There is no way to handle allocation failure of only 16 bytes. + * Let's simplify error handling and save more memory. + */ + ld = kmalloc(sizeof(struct tty_ldisc), GFP_KERNEL | __GFP_NOFAIL); ld->ops = ldops; ld->tty = tty;