Received: by 10.192.165.148 with SMTP id m20csp4192181imm; Mon, 30 Apr 2018 13:33:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq2d+RXNjv3kzkM+cZTRmc9i5D+5eE7fP5MGDLw8I0i3xkuGFNmvxmsTzJdHy5DOVxDt1Xk X-Received: by 10.98.60.209 with SMTP id b78mr12981622pfk.44.1525120412696; Mon, 30 Apr 2018 13:33:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525120412; cv=none; d=google.com; s=arc-20160816; b=jAZQVWPedKnCXyv5ifKasY4BYVFSEoLiMNOoTsHbcjLhdlaycnjuFQiuvvWWZOBgkj hR+Cz8LqgdbkoRupHuP8em/iXnORIGroj6gWQG9l1+DwXDJXRXdup3bxYKDNLP+MzZdh r1hZHR+83qt5yvvh8pnssdlnOiDi2lcwArfzazWPmJbm6DucUK0kDladR9rRd6z9LYa6 Pwk2gKjEEr6VotTzoLEutsjVyLu1tzp+z5hiS4HoxUtWH7KKV0LwuTtrTjgtR2aK9qaW pjihhKGYKOR1QDFYHwbFwWNDdxTEXwK8wOFfRWDKbyo7ODBFX4RCevVd05VjJtEzy0un A0gQ== 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=HjzndYgWAxmyz00ycVK6o2yyr26VrC7ZxcOxvL9lhYM=; b=TE4+ln34PWov0MDy/eQM4fce/LEJgHLYLMSctnfakzKizwQiaDMSJZlTTRZSDbccwI vlBxaP3YsTWZypZ5bK1LZeo0SPG8LHDOi2Qfc7AqVIHMXayirQ89iOWLedcVAJtf6g8x TvPx76IzY5xww9n3u4XSt+G/yFpt3HdFwcWxnODvRc//hJO6PZWdzu/AHwd6HtdqInp4 zKGuWsdb24uFhwKfpWv6zevmyMCQz4nFlSlamjOQvgQ2zUy4hmZ+iysFjHdZB6UkA1Cu uOLEW6cip8VGxwkAVXb/1Xsnw4xOV8OrUlCmLYm55X6AyuB5zp7wGnLpsTnwc/IRKDyd hSyg== 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 v4-v6si8013792ply.351.2018.04.30.13.33.18; Mon, 30 Apr 2018 13:33:32 -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 S1755584AbeD3Ubs (ORCPT + 99 others); Mon, 30 Apr 2018 16:31:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:59252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755465AbeD3T0I (ORCPT ); Mon, 30 Apr 2018 15:26:08 -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 3502322DCC; Mon, 30 Apr 2018 19:26:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3502322DCC 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.4 19/44] tty: Use __GFP_NOFAIL for tty_ldisc_get() Date: Mon, 30 Apr 2018 12:24:30 -0700 Message-Id: <20180430190947.110953301@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430190946.093694747@linuxfoundation.org> References: <20180430190946.093694747@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.4-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 @@ -168,12 +168,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;