Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6641015imu; Sun, 2 Dec 2018 23:47:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/U0BGSkaMc15DiogqsA3fPCPApiD4Q1aGgkfNmvO/iWfafcVXh9FEnYye6Hb7Svw+EUfmWX X-Received: by 2002:a63:8043:: with SMTP id j64mr12678021pgd.405.1543823275290; Sun, 02 Dec 2018 23:47:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543823275; cv=none; d=google.com; s=arc-20160816; b=xCg0d4MNMYiWkFUuagNgI4OJbSyNTpq/f6EPiRp5W3US/QX/WRLckdbDCcD1b9grNX 3lldG07uuX7XzHVC0qGDt8bWJUJYpWypOOHAOy2Ud25wTKIbjY30aaPY8176abTx4lNk xIg+8WmuTjkJ7Ry77spT5p2R8EZMLk0F++fvjI7HsVdpaZgb+XMDpttKEnx6ozWBLlqO NN85ZXrRX5M3wWYiSrI5aUBZlVpE6DYrqvD0pVmk23mIcyujZOtoyXJtmtwk2mJvtmju x+vbbhtpqgGf9UV+/kcaCEgjsVh1hBvHMeGvKJvhZV9vfo0UNYFS+9eKGSEs5wp91WfG V4jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=6lV8j+G7Xpem+oMI5fU07V0dy1BJ8+B6EqyreIDFMtY=; b=0jCwZmadkmIMwVvKdqpXNsUKFzzYe56pUhyHJKHh6iOeZeb+QZl6UQcwJFLP8lsI5v NmtTUNtXE4pZSeTUv7B+gyWen+TZNwSObbrCCK2k4vpCDPaVh52BKobK1gAOkGES6mp/ xiRIsL0qTuWXLo3tpdkZhKHZsha+jWWeYbqKZOX/DH8cXgyPyVelML28dmzUfruifVo6 tm+lR9FcgC/Iq5swxj2KeF/Qvoqzjjymk9CmgCtw2cjz0i/NcqHhdknSTbzEOvGnTr/N RXpYsAne4W2SKKCQyGkN8k2MptGt8FSeMGn6sbmRKMQlQ0VsS7WCav5qYRq7Re7RdIv2 LfYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=QVIGNN+3; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l8si12658626pgr.345.2018.12.02.23.47.40; Sun, 02 Dec 2018 23:47:55 -0800 (PST) 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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=QVIGNN+3; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725861AbeLCHrJ (ORCPT + 99 others); Mon, 3 Dec 2018 02:47:09 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:40412 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725829AbeLCHrJ (ORCPT ); Mon, 3 Dec 2018 02:47:09 -0500 Received: by mail-wm1-f66.google.com with SMTP id q26so4523376wmf.5 for ; Sun, 02 Dec 2018 23:47:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=6lV8j+G7Xpem+oMI5fU07V0dy1BJ8+B6EqyreIDFMtY=; b=QVIGNN+3BvEMcJrtmsjKQNPG3Fcpvc+B7b8tCEQCXRrZwQucXwitlgb04ogdoK8CRa w/dUIe/oE12GNjwqMducrAuIz32TifA3RUPKFnpWdSXwftBkh41pmKkwE/iDGfLhjoFZ AbAyevk6qLm3fNLI27ppwNmXGXEMcAKXf5MwL9zrkr8p88i5hNchcOXjPpw9QDWFsQ7R lgtF7UvbekbGXymXG0BUqtGOwj3JwVbSjiUgXrwTTZn9v6H5gisZj3GoA3EcJXrFdnlP 6X0AdgVKfB2OEz9bZvNfOpyiqaYO4sAXI5MYoFu3/ukjFZzSJcIJQ7o9Q6EqiNe/f3fY vYMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=6lV8j+G7Xpem+oMI5fU07V0dy1BJ8+B6EqyreIDFMtY=; b=j2Q/pllDmfjp+B5uidyQqHw05sAf8yZZCD8Swk/qW0DXbKxlyug6EtC7eGsF0MeeyY Dg5Am7ZGihk4hGktJJ1TZBowhJVnrhTWKzd2APc0FANsAxQ6Ox+tPV7D+hLXZxFA8mMa 0LD0//hSTCIKJlhuFAKuL3ROf1CngrPidS4BgalfINye5iIHYjNsq5pERFtRfKvu7ym3 Q0/ARkp7MeCBzfgBttnLroSAdshyW8ZsocH0Imtq6DoWQ3gspaO7kEEebylhLWUr9x0t ba5JX6ies6Slbf/9Uc3E9mujpL23tkbbAHqsZBm+6ET3PStTjpNFMxpGIbblBqkj9lDx YBBg== X-Gm-Message-State: AA+aEWa6u8lxOr8ucZKDxzN5rA3mCyRz7V7+o54z/psYm+5PnojXaLvj J2FlrPnKBXXwr/KRi/mRaNQ= X-Received: by 2002:a1c:1903:: with SMTP id 3-v6mr6873079wmz.141.1543823223376; Sun, 02 Dec 2018 23:47:03 -0800 (PST) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id j76sm19059873wmf.26.2018.12.02.23.47.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 02 Dec 2018 23:47:02 -0800 (PST) Date: Mon, 3 Dec 2018 08:47:00 +0100 From: Ingo Molnar To: Linus Torvalds Cc: Linux List Kernel Mailing , "Rafael J. Wysocki" , Chanho Min , Thomas Gleixner , Peter Zijlstra , Oleg Nesterov , Pavel Machek , Michal Hocko Subject: [PATCH] Revert "exec: make de_thread() freezable (was: Re: Linux 4.20-rc4) Message-ID: <20181203074700.GA21240@gmail.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Linus Torvalds wrote: > The patch stats this week look a little bit more normal than last tim, > probably simply because it's also a normal-sized rc4 rather than the > unusually small rc3. So there's a new regression in v4.20-rc4, my desktop produces this lockdep splat: [ 1772.588771] WARNING: pkexec/4633 still has locks held! [ 1772.588773] 4.20.0-rc4-custom-00213-g93a49841322b #1 Not tainted [ 1772.588775] ------------------------------------ [ 1772.588776] 1 lock held by pkexec/4633: [ 1772.588778] #0: 00000000ed85fbf8 (&sig->cred_guard_mutex){+.+.}, at: prepare_bprm_creds+0x2a/0x70 [ 1772.588786] stack backtrace: [ 1772.588789] CPU: 7 PID: 4633 Comm: pkexec Not tainted 4.20.0-rc4-custom-00213-g93a49841322b #1 [ 1772.588792] Call Trace: [ 1772.588800] dump_stack+0x85/0xcb [ 1772.588803] flush_old_exec+0x116/0x890 [ 1772.588807] ? load_elf_phdrs+0x72/0xb0 [ 1772.588809] load_elf_binary+0x291/0x1620 [ 1772.588815] ? sched_clock+0x5/0x10 [ 1772.588817] ? search_binary_handler+0x6d/0x240 [ 1772.588820] search_binary_handler+0x80/0x240 [ 1772.588823] load_script+0x201/0x220 [ 1772.588825] search_binary_handler+0x80/0x240 [ 1772.588828] __do_execve_file.isra.32+0x7d2/0xa60 [ 1772.588832] ? strncpy_from_user+0x40/0x180 [ 1772.588835] __x64_sys_execve+0x34/0x40 [ 1772.588838] do_syscall_64+0x60/0x1c0 The warning gets triggered by an ancient lockdep check in the freezer: (gdb) list *0xffffffff812ece06 0xffffffff812ece06 is in flush_old_exec (./include/linux/freezer.h:57). 52 * DO NOT ADD ANY NEW CALLERS OF THIS FUNCTION 53 * If try_to_freeze causes a lockdep warning it means the caller may deadlock 54 */ 55 static inline bool try_to_freeze_unsafe(void) 56 { 57 might_sleep(); 58 if (likely(!freezing(current))) 59 return false; 60 return __refrigerator(false); 61 } I reviewed the ->cred_guard_mutex code, and the mutex is held across all of exec() - and we always did this. But there's this recent -rc4 commit: > Chanho Min (1): > exec: make de_thread() freezable c22397888f1e: exec: make de_thread() freezable I believe this commit is bogus, you cannot call try_to_freeze() from de_thread(), because it's holding the ->cred_guard_mutex. Also, I'm 3 times grumpy: #1: I think this commit was never tested with lockdep turned on, as I think splat this should trigger 100% of the time with the ELF binfmt loader. #2: Less than 4 days passed between the commit on Nov 19 and it being upstream by Nov 23. *Please* give it more testing if you change something as central as fs/exec.c ... #3 Also, please also proof-read changelogs before committing them: >> The casue is that de_thread() sleeps in TASK_UNINTERRUPTIBLE waiting for >> [...] >> >> In our machine, it causes freeze timeout as bellows. That's *three* typos in a single commit: s/casue/cause s/In our/On our s/bellows/below ... Grump! :-) Note that I haven't tested the revert yet, but the code and the breakage looks pretty obvious. (I'll boot the revert, will follow up if that didn't solve the problem.) Thanks, Ingo Signed-off-by: Ingo Molnar This reverts commit c22397888f1eed98cd59f0a88f2a5f6925f80e15. --- fs/exec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index acc3a5536384..fc281b738a98 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -62,7 +62,6 @@ #include #include #include -#include #include #include @@ -1084,7 +1083,7 @@ static int de_thread(struct task_struct *tsk) while (sig->notify_count) { __set_current_state(TASK_KILLABLE); spin_unlock_irq(lock); - freezable_schedule(); + schedule(); if (unlikely(__fatal_signal_pending(tsk))) goto killed; spin_lock_irq(lock); @@ -1112,7 +1111,7 @@ static int de_thread(struct task_struct *tsk) __set_current_state(TASK_KILLABLE); write_unlock_irq(&tasklist_lock); cgroup_threadgroup_change_end(tsk); - freezable_schedule(); + schedule(); if (unlikely(__fatal_signal_pending(tsk))) goto killed; }