Received: by 10.192.165.148 with SMTP id m20csp4153456imm; Mon, 30 Apr 2018 12:47:00 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqJL8iAsQMsg4ggUUafvd5MFOZMml/2SpuGj4hZaKa+dQaSbt/aVIu75k6eaD5v3+UcFDJN X-Received: by 2002:a63:6f81:: with SMTP id k123-v6mr11144685pgc.115.1525117620238; Mon, 30 Apr 2018 12:47:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525117620; cv=none; d=google.com; s=arc-20160816; b=EIG46XWTkidnCowfXY1kzkK+dFt2l7xMshQCo05wVaw39lO/0VPqsSheW0QHTAwVs8 ELP80fnoeDtxFbgp4vgBF5f9oYQ7sdm2g6ASfmN8YPYdctTCY80vwQl0xde6e131hudf fXV7yUTpq2wW0lHkRHnEQvWeepQaL8giVDRN12UhacN/o6eBFTRw+BxQgVNr1AKWGK1m Q713TcUBIK6lcpIQtiub1BwDICaeq55XRK0HTSBmvcSuvHq7FQpUHKB5tZAokCylRe5e B9TXH5d+GdY8V3n+jIbumUnIXpJwtYePzLnggTd6FUTmyKcrNGOv51JxM2RFGtukSqxN GFPg== 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=vb3KhJ+n7LuF6fb01CKvOyriawElNUDDwO7XDf3bG3I=; b=h11/7eXbhIEophZY7z8Ofdelpup01FAFGInjWlkpMDRFwlPC2al9qO4zxN01qV4pPJ HUPDXuvTgdXySkiWL8nVoYBNJIjpLWXt50T6/Hswe56m1GPNZcV0T/45vLZTKYMQtFGB xKFSrOEOysHpSzpNGe6WX9pIeka3PS8Lm+WVUw2bvZdNBBdqd4lU4mr483hkbvvsydO/ OMOCN0me25N8/8FA+vKLwcq+MAcH5LBDxOqyFXJzDbdo+5j1dJLqhgQNHRQNgWkSb401 hJB7odhrGW38PPyJc64x8cmJktZwfdQ0nIA1xt7UBwjVy2VRf1wEft03vofLfzumOipX lQ2w== 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 g63si8113179pfd.93.2018.04.30.12.46.45; Mon, 30 Apr 2018 12:47: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 S932271AbeD3T2X (ORCPT + 99 others); Mon, 30 Apr 2018 15:28:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:35690 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756232AbeD3T2O (ORCPT ); Mon, 30 Apr 2018 15:28:14 -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 77DC722DAC; Mon, 30 Apr 2018 19:28:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 77DC722DAC 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.16 035/113] tty: Use __GFP_NOFAIL for tty_ldisc_get() Date: Mon, 30 Apr 2018 12:24:06 -0700 Message-Id: <20180430184016.538852024@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184015.043892819@linuxfoundation.org> References: <20180430184015.043892819@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.16-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 @@ -176,12 +176,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;