From patchwork Tue Aug 28 20:13:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 145359 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1589121ljw; Tue, 28 Aug 2018 13:13:42 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbWNXDO5A3ym4V/AWcXUPcYtrZAmdhKurFiXKHPoQSjpwZTt+pvAAjmC7xCet5/pB12l4Do X-Received: by 2002:a17:902:9a01:: with SMTP id v1-v6mr2922930plp.20.1535487222224; Tue, 28 Aug 2018 13:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535487222; cv=none; d=google.com; s=arc-20160816; b=WZtUkrCuJGtFV2dJ6OL+UcNIt6O1A60KHOi4HqjLLGCXS3lcotvDmFJW+3Jnf73cwM UxAHRNat2obvza9prFevPgukxv/yOgTAQ380H9nrzG/CGnHflQg8gU6LKYNXD2E04f7X sRgoE3XjHNszK3E0/g+Kvt0LavHAPqIwmSW5xevdcoDKkz/c2JiEjdbS9z7qfY1LbZm2 r+SEX+3izysXiiD1XrRqogY3aBD817hnKpKkYyUERDo0ToljdVsEYv9ebS4JIClj8s07 +4+aTiThya4TzzJ+O8hQTasTltX1I4f5QrEfG6es7m6+uGfdrm18YTc20ZGejFvXXwwK uIyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Nrx5BjLid6WRT0H+QOg8OOAOoYWBRl3aOyPeYKp49o8=; b=Jo/VluBjLaW055PTKsh4124v1lbGX7vzfSx3jQRAy+JKriDWmX/GmPQw2spKoN4sJi m2XVxv+EVrAXi20YBMulAWeR7bRQKX7G+SGNpMpzfImnGmRLnIAF5t9OiTKXZwtqKiDh bVS+hf62Gke0GTNMlkD8rFxz0apQEC6mWf6Sw+wmEqrVrxIOQ2Di7/3KkrKjoW750pKY 6+GF93XqYt/J8J6fW8Ie4qhgW7qqHaau180JzGzz2DLGUnBSSQ0M+pkp9bvoMZexzAlu QlFVBEn6QQwXONlW+w38lUz/nmHbbV2rLSJpXmYkE1GAlnDMwD2jDDlC2cWAM1nL0FqA 370w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ORg3rM9p; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y10-v6si1906969pgf.312.2018.08.28.13.13.42; Tue, 28 Aug 2018 13:13:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ORg3rM9p; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727098AbeH2AGz (ORCPT + 13 others); Tue, 28 Aug 2018 20:06:55 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:40889 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726961AbeH2AGz (ORCPT ); Tue, 28 Aug 2018 20:06:55 -0400 Received: by mail-pf1-f193.google.com with SMTP id s13-v6so1194762pfi.7 for ; Tue, 28 Aug 2018 13:13:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Nrx5BjLid6WRT0H+QOg8OOAOoYWBRl3aOyPeYKp49o8=; b=ORg3rM9pJcwi49nThhGQpNPutYZBoA/O1ef4eqv121X6OBjeGxolkgnBpuB0eoWRiz 1LngNeT655sV1/LHNHc+GZuS31pBFBtZKb7CMgZ6zgiuuHWg3hWeGv9PJq3rp0a1jAwz 4adSGw6C3lFKRLwSKyWlcTIdLcMdM8gaZIRi4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Nrx5BjLid6WRT0H+QOg8OOAOoYWBRl3aOyPeYKp49o8=; b=r5VZfoT3JNyZerEIHtmI3qBvyaEfss2/WLgRrz7C7f+JnLMB1uHNPtOZ3BiuTi3yhM 20kUboIRhf7Ykjbu48h6CI6BS8GyGv+XZ5BBmEQxZ+7+5bvaBGnKKibTqA2ZAek8hqq4 K1GvCxwr6QvHp0X3K3PWavlXr8UCZCaSpqWIDx5WLmwrTD+WE8uArnri8h6zPJ1qK2N3 8IJQcPH4BtE6vSTdc6fsQZI9B+J2UAmnXg5DI1+wv30ZHfbUPHnyk8Lz/WeBMDdwmvxz GmBsst0ZLEyufI3d01sBadvlKz15ZsAMEQym9GucjyeolEiLg91n6XQIQ5UlOMytzwZT xbNw== X-Gm-Message-State: APzg51AHjN/4bfbOA2oh4DclXuIpGr0iqVD8q7wLoDbwia/HP/mfyj1J AtdmgUISIekYYz+vAJ9/e3kCYw== X-Received: by 2002:a62:808c:: with SMTP id j134-v6mr2969815pfd.120.1535487220306; Tue, 28 Aug 2018 13:13:40 -0700 (PDT) Received: from localhost.localdomain ([49.207.48.21]) by smtp.gmail.com with ESMTPSA id t86-v6sm3098181pfe.109.2018.08.28.13.13.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Aug 2018 13:13:38 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Vegard Nossum , Ralf Baechle , linux-mips@linux-mips.org, Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org, Jamie Iles , Thomas Gleixner , Linus Torvalds Subject: [PATCH for-4.9.y 03/14] kthread: fix boot hang (regression) on MIPS/OpenRISC Date: Wed, 29 Aug 2018 01:43:14 +0530 Message-Id: <1535487205-26280-4-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535487205-26280-1-git-send-email-amit.pundir@linaro.org> References: <1535487205-26280-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Vegard Nossum commit b0f5a8f32e8bbdaae1abb8abe2d3cbafaba57e08 upstream. This fixes a regression in commit 4d6501dce079 where I didn't notice that MIPS and OpenRISC were reinitialising p->{set,clear}_child_tid to NULL after our initialisation in copy_process(). We can simply get rid of the arch-specific initialisation here since it is now always done in copy_process() before hitting copy_thread{,_tls}(). Review notes: - As far as I can tell, copy_process() is the only user of copy_thread_tls(), which is the only caller of copy_thread() for architectures that don't implement copy_thread_tls(). - After this patch, there is no arch-specific code touching p->set_child_tid or p->clear_child_tid whatsoever. - It may look like MIPS/OpenRISC wanted to always have these fields be NULL, but that's not true, as copy_process() would unconditionally set them again _after_ calling copy_thread_tls() before commit 4d6501dce079. Fixes: 4d6501dce079c1eb6bf0b1d8f528a5e81770109e ("kthread: Fix use-after-free if kthread fork fails") Reported-by: Guenter Roeck Tested-by: Guenter Roeck # MIPS only Acked-by: Stafford Horne Acked-by: Oleg Nesterov Cc: Ralf Baechle Cc: linux-mips@linux-mips.org Cc: Jonas Bonn Cc: Stefan Kristiansson Cc: openrisc@lists.librecores.org Cc: Jamie Iles Cc: Thomas Gleixner Signed-off-by: Vegard Nossum Signed-off-by: Linus Torvalds Signed-off-by: Amit Pundir --- To be applied on 4.4.y and 3.18.y as well. Build tested on v4.4.153 and v3.18.120. arch/mips/kernel/process.c | 1 - arch/openrisc/kernel/process.c | 2 -- 2 files changed, 3 deletions(-) -- 2.7.4 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index 513a63b9b991..ba315e523b33 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c @@ -118,7 +118,6 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, struct thread_info *ti = task_thread_info(p); struct pt_regs *childregs, *regs = current_pt_regs(); unsigned long childksp; - p->set_child_tid = p->clear_child_tid = NULL; childksp = (unsigned long)task_stack_page(p) + THREAD_SIZE - 32; diff --git a/arch/openrisc/kernel/process.c b/arch/openrisc/kernel/process.c index 7095dfe7666b..962372143fda 100644 --- a/arch/openrisc/kernel/process.c +++ b/arch/openrisc/kernel/process.c @@ -152,8 +152,6 @@ copy_thread(unsigned long clone_flags, unsigned long usp, top_of_kernel_stack = sp; - p->set_child_tid = p->clear_child_tid = NULL; - /* Locate userspace context on stack... */ sp -= STACK_FRAME_OVERHEAD; /* redzone */ sp -= sizeof(struct pt_regs);