From patchwork Tue Aug 28 20:13:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 145357 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1589047ljw; Tue, 28 Aug 2018 13:13:34 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY+L7rK43BCwtjA/eU6qr7FEZiJdmVe0nj7M8YUm/S/TY5AZBadOzAq1wf6vc6+7z5TqxMG X-Received: by 2002:aa7:82c3:: with SMTP id f3-v6mr3018821pfn.136.1535487214645; Tue, 28 Aug 2018 13:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535487214; cv=none; d=google.com; s=arc-20160816; b=yOWv3cpCF7QNZVuW1B9hxd2ENvKXxy8IkDvFl8rab3xq0ByW6LBAhR8lluetF95TPX rtbkEy7RCLoc16t4arN+RiLtyF1BAE+6S+Aq+S72VpI3NlcLrDeZTA8QvLjkNGLbHURL HdinTyct2ms45LKMzl3dXvxXYC3w42VUrj5SUsWhvIuS4y/6jmCjh/mtgrgLH4Z4AAZI UGH2btteqKZtaxJfZb/x86oGClHIY2Zkiib6NP34JY4/pNLncR2DfX3hRyflHgAtKIsi yCxIW6mJz9n3cG9BqMa9cRj4IeUre8GqVzSzAHye/zFBAXUcwp+PYgzm+8S0IWQ4dMmh 6VnQ== 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=uTxbwUJmgHgwa7qp/t6pD6Zjr61gDIpQmZVcGnDL6DQ=; b=ukEtuYaeGNP5gJa6Mu4CxtbdDDTu6yC7gq7E8a1jYPRb/SV10dXaa/7SgqCh1/9djD yYDTODyk5GIV6D0NpLDSx/EDzLsWduqw4FqG2mE+e0PuabD+aSHMphdgyWTYzAn3GD+H YuRnGWaOtMHld68V+rRERV+uGdbBpnnfJAwNH71GQlQwZjNAntdDaT3L+gSyl4HcHv6p mHFDRAwUoSaYBA2VkqlVwXXvPtQVbGG9+g/8LkBZPwiMpj26mDsS3lNJvYOsKAc1lfuJ 74p/4+M68x0LVoxSMD705v2B9pyYI6TM/cHQXRHfUScl5vC3RbtNnmoBE2oWDGPaytme 2+Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dvMGoOCI; 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.34; Tue, 28 Aug 2018 13:13:34 -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=dvMGoOCI; 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 S1727054AbeH2AGr (ORCPT + 13 others); Tue, 28 Aug 2018 20:06:47 -0400 Received: from mail-pg1-f179.google.com ([209.85.215.179]:33736 "EHLO mail-pg1-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726961AbeH2AGr (ORCPT ); Tue, 28 Aug 2018 20:06:47 -0400 Received: by mail-pg1-f179.google.com with SMTP id y3-v6so21784pgv.0 for ; Tue, 28 Aug 2018 13:13:33 -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=uTxbwUJmgHgwa7qp/t6pD6Zjr61gDIpQmZVcGnDL6DQ=; b=dvMGoOCIwF9JUk0E+18pCiYrK/i5PuY6bYenMAYYwvX+fk54WVdTMzbO1W79ncshTM qrq2/ywHoAj0rtVp//0+uvZFBf00n72RjiOUcGJ4trrRi8FMtf+AC45kNwkEt7n07sU2 op7tGy9nElWruzK9mqrqlFis2LZ4BQBK70AqM= 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=uTxbwUJmgHgwa7qp/t6pD6Zjr61gDIpQmZVcGnDL6DQ=; b=pHPE5uN7vsMCSJVlPJLyemXBuIAjtMkMQg9wlBsjqri5T0yG9exnv63/iYup28hiBQ wCng1TOEJTka5mqrA1vyaEVN/p4aRd+aI0rtLHgmHX3vl1PpQ6RJw/5jd/nV67h+qKmH Px0TbZkZaTciyN1BXSs4s+oI/NdEOMzpjBVQ5zkMoP2bmgqTLKQULiUTGI8fJ5k1IJmV m+ZG9L4qppsdwzSwyXt29qp1rlQHnfwh7t6i4j5uguRZbhGYkv1PmQ9Fr8zDK2bOg78j xGJ4li0sxAEkTTwEcdL4LMkwviFPDKvlwLjAhmfllPIAcDSKLtcbFQFMW50KdKIw/sF7 XBaA== X-Gm-Message-State: APzg51CKESbjAb47lApIL9XjVrkn8FLrb1enUbCWkDtA/ryXjbirS0c2 ERcGVvLbvoebMeVTDiIn9Cf6IqYhU6s= X-Received: by 2002:a62:444d:: with SMTP id r74-v6mr2961078pfa.96.1535487212509; Tue, 28 Aug 2018 13:13:32 -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.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Aug 2018 13:13:31 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Ritesh Harjani , Jens Axboe Subject: [PATCH for-4.9.y 01/14] cfq: Give a chance for arming slice idle timer in case of group_idle Date: Wed, 29 Aug 2018 01:43:12 +0530 Message-Id: <1535487205-26280-2-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: Ritesh Harjani commit b3193bc0dca9bb69c8ba1ec1a318105c76eb4172 upstream. In below scenario blkio cgroup does not work as per their assigned weights :- 1. When the underlying device is nonrotational with a single HW queue with depth of >= CFQ_HW_QUEUE_MIN 2. When the use case is forming two blkio cgroups cg1(weight 1000) & cg2(wight 100) and two processes(file1 and file2) doing sync IO in their respective blkio cgroups. For above usecase result of fio (without this patch):- file1: (groupid=0, jobs=1): err= 0: pid=685: Thu Jan 1 19:41:49 1970 write: IOPS=1315, BW=41.1MiB/s (43.1MB/s)(1024MiB/24906msec) <...> file2: (groupid=0, jobs=1): err= 0: pid=686: Thu Jan 1 19:41:49 1970 write: IOPS=1295, BW=40.5MiB/s (42.5MB/s)(1024MiB/25293msec) <...> // both the process BW is equal even though they belong to diff. cgroups with weight of 1000(cg1) and 100(cg2) In above case (for non rotational NCQ devices), as soon as the request from cg1 is completed and even though it is provided with higher set_slice=10, because of CFQ algorithm when the driver tries to fetch the request, CFQ expires this group without providing any idle time nor weight priority and schedules another cfq group (in this case cg2). And thus both cfq groups(cg1 & cg2) keep alternating to get the disk time and hence loses the cgroup weight based scheduling. Below patch gives a chance to cfq algorithm (cfq_arm_slice_timer) to arm the slice timer in case group_idle is enabled. In case if group_idle is also not required (including for nonrotational NCQ drives), we need to explicitly set group_idle = 0 from sysfs for such cases. With this patch result of fio(for above usecase) :- file1: (groupid=0, jobs=1): err= 0: pid=690: Thu Jan 1 00:06:08 1970 write: IOPS=1706, BW=53.3MiB/s (55.9MB/s)(1024MiB/19197msec) <..> file2: (groupid=0, jobs=1): err= 0: pid=691: Thu Jan 1 00:06:08 1970 write: IOPS=1043, BW=32.6MiB/s (34.2MB/s)(1024MiB/31401msec) <..> // In this processes BW is as per their respective cgroups weight. Signed-off-by: Ritesh Harjani Signed-off-by: Jens Axboe 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. block/cfq-iosched.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index c7c3d4e6bc27..b2dc1c1f08c6 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c @@ -2951,7 +2951,8 @@ static void cfq_arm_slice_timer(struct cfq_data *cfqd) * for devices that support queuing, otherwise we still have a problem * with sync vs async workloads. */ - if (blk_queue_nonrot(cfqd->queue) && cfqd->hw_tag) + if (blk_queue_nonrot(cfqd->queue) && cfqd->hw_tag && + !cfqd->cfq_group_idle) return; WARN_ON(!RB_EMPTY_ROOT(&cfqq->sort_list)); From patchwork Tue Aug 28 20:13:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 145358 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1589068ljw; Tue, 28 Aug 2018 13:13:37 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZETn3JP4MYdvGiMnjB7JVXdmK9KfFs8LOiF40TLBMpRHwouWQ02LidSSjrLV/lN7e/+tJx X-Received: by 2002:a17:902:7798:: with SMTP id o24-v6mr2916572pll.93.1535487217437; Tue, 28 Aug 2018 13:13:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535487217; cv=none; d=google.com; s=arc-20160816; b=zcUfZ704c7sIoPj2Q6bRgVThXSjxdVYhZnLdNr0I9y+246P1iYch1SB0xm8cvm8o2E VKa30GVv/MV/vb5bRRk2oR0oubgiu+Bsj+2VOZWnfxo5Z4VH7yiJIIezEC2q0+WamDtY bR/csj7K277EjVqTTlaeDCnjCLjFoQQJxsiI8r7Q0nURMc7wCovsEttCc0odm+5dA0YJ Kbc0vRCQie99QXDJ5Gs/jVIJgwGpJ+w1vZ1IalBbUiQWkCsoU0e4hr6UVRFBZasw7og/ jXhm5IWqdUZwO8NZI2kXDYJt3pQPBn6SG5+AAAcJJ5fqzf8FZ7apKIvGOX0+X6LeEm1g /cgQ== 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=npEd73737ocTlcqIyMwBUjQJ/UmyDyHqx83Mw3n4NgM=; b=H6QMwbCNa33tuXhYK1fYWmZ+AKg7Din4NrLpg2ryYaF+YB/FLceVrxflQwaEts7SHf ZI4l2BL9bkSWfPIFH4E8rcToGZWG0BH0P4lJD2zTOy5uHXahET/QFlguPsnRQWilbfl1 WKEfgExZFOtmZhERR3Ix6ZNvNvnT/XA+9qyBQgIyxDVqr6Hwsg0QvSmHePm4AtMshUjq /DYJNGA9VDF3hfjiLcCUsaaWjB+k+Unj2hZfc3lr3v+qeMmq5urnkX9pzKPHurFIKShx gZ3CBNY5sha/DNm6JHwQsQFti3gDN2GzRc7kok9r8Pm3UIfUP+u2xIrI31FyhFUOPoto Ga3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="A8QHVgM/"; 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.37; Tue, 28 Aug 2018 13:13:37 -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="A8QHVgM/"; 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 S1727086AbeH2AGu (ORCPT + 13 others); Tue, 28 Aug 2018 20:06:50 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:43726 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726961AbeH2AGu (ORCPT ); Tue, 28 Aug 2018 20:06:50 -0400 Received: by mail-pl1-f193.google.com with SMTP id x6-v6so1196362plv.10 for ; Tue, 28 Aug 2018 13:13:36 -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=npEd73737ocTlcqIyMwBUjQJ/UmyDyHqx83Mw3n4NgM=; b=A8QHVgM/eLYudGOmpnQW87Xv+1KEPlkAmL0REUtI9riABWncsedZrXxJvD0Pzx52Qu uOBbrad4UILwS3ENgtmgEpbuY22cTvXfpX4FfLti3Mk9wEROQwasF8AX/Jh79UQrFkj3 ICLam+w3WbVYDi432ds2FLt9h3vq80slLyLok= 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=npEd73737ocTlcqIyMwBUjQJ/UmyDyHqx83Mw3n4NgM=; b=SnBLbPFK9uaupSctrYyGCy2incfi0iZi3AFTiSP3FUCVH4SrjAg9od+QtGjKO3VFr8 05Gcmsi6If8NJbMaN3QsZUvAE+Y9wr4hhjzY236q6U/KoJJK1W2BXN838o+tuLzfUyoC eyICJ8LIWaTQ4JcZCEda5xKevZreyo2sz2paOU50Ly8i4pD/IU5wzYsKOTQOYn0xgu+c K6nhmg0IAPHUYK6qPtJBRe0Os8WudYK4FcPth/y5FBxpLgY6aHJKWmpM3S12ZYpjfG7y 95/Cns9zO6h8UdP1pBLetm5byC2Eqx2im/Y1acu9qF0QPdooyfdBHEit2ajqU5j5gjKh YQBA== X-Gm-Message-State: APzg51CYiLaANvP+hbtIHX4EGjFQQb4yO48gBlfQJmMi7b4YKcEPYIW1 bGRGsquRz3guzJHfySbnoMAzRA== X-Received: by 2002:a17:902:27a8:: with SMTP id d37-v6mr2936520plb.290.1535487215966; Tue, 28 Aug 2018 13:13:35 -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.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Aug 2018 13:13:34 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Vegard Nossum , Peter Zijlstra , Andy Lutomirski , Frederic Weisbecker , Jamie Iles , Thomas Gleixner Subject: [PATCH for-4.9.y 02/14] kthread: Fix use-after-free if kthread fork fails Date: Wed, 29 Aug 2018 01:43:13 +0530 Message-Id: <1535487205-26280-3-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 4d6501dce079c1eb6bf0b1d8f528a5e81770109e upstream. If a kthread forks (e.g. usermodehelper since commit 1da5c46fa965) but fails in copy_process() between calling dup_task_struct() and setting p->set_child_tid, then the value of p->set_child_tid will be inherited from the parent and get prematurely freed by free_kthread_struct(). kthread() - worker_thread() - process_one_work() | - call_usermodehelper_exec_work() | - kernel_thread() | - _do_fork() | - copy_process() | - dup_task_struct() | - arch_dup_task_struct() | - tsk->set_child_tid = current->set_child_tid // implied | - ... | - goto bad_fork_* | - ... | - free_task(tsk) | - free_kthread_struct(tsk) | - kfree(tsk->set_child_tid) - ... - schedule() - __schedule() - wq_worker_sleeping() - kthread_data(task)->flags // UAF The problem started showing up with commit 1da5c46fa965 since it reused ->set_child_tid for the kthread worker data. A better long-term solution might be to get rid of the ->set_child_tid abuse. The comment in set_kthread_struct() also looks slightly wrong. Debugged-by: Jamie Iles Fixes: 1da5c46fa965 ("kthread: Make struct kthread kmalloc'ed") Signed-off-by: Vegard Nossum Acked-by: Oleg Nesterov Cc: Peter Zijlstra Cc: Greg Kroah-Hartman Cc: Andy Lutomirski Cc: Frederic Weisbecker Cc: Jamie Iles Cc: stable@vger.kernel.org Link: http://lkml.kernel.org/r/20170509073959.17858-1-vegard.nossum@oracle.com Signed-off-by: Thomas Gleixner 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. kernel/fork.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/kernel/fork.c b/kernel/fork.c index 2c98b987808d..46a6b0311ca3 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1530,6 +1530,18 @@ static __latent_entropy struct task_struct *copy_process( if (!p) goto fork_out; + /* + * This _must_ happen before we call free_task(), i.e. before we jump + * to any of the bad_fork_* labels. This is to avoid freeing + * p->set_child_tid which is (ab)used as a kthread's data pointer for + * kernel threads (PF_KTHREAD). + */ + p->set_child_tid = (clone_flags & CLONE_CHILD_SETTID) ? child_tidptr : NULL; + /* + * Clear TID on mm_release()? + */ + p->clear_child_tid = (clone_flags & CLONE_CHILD_CLEARTID) ? child_tidptr : NULL; + ftrace_graph_init_task(p); rt_mutex_init_task(p); @@ -1691,11 +1703,6 @@ static __latent_entropy struct task_struct *copy_process( } } - p->set_child_tid = (clone_flags & CLONE_CHILD_SETTID) ? child_tidptr : NULL; - /* - * Clear TID on mm_release()? - */ - p->clear_child_tid = (clone_flags & CLONE_CHILD_CLEARTID) ? child_tidptr : NULL; #ifdef CONFIG_BLOCK p->plug = NULL; #endif 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); From patchwork Tue Aug 28 20:13:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 145360 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1589143ljw; Tue, 28 Aug 2018 13:13:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbBUUmuSNqk3+PeL9KLBL2puWTT5qZ1gUYKfIoaCy6QPOKiEmdcYsimhoJ4c45EHWB+toqX X-Received: by 2002:a17:902:e190:: with SMTP id cd16-v6mr2879357plb.305.1535487224859; Tue, 28 Aug 2018 13:13:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535487224; cv=none; d=google.com; s=arc-20160816; b=sYH5MV3GJvisi1gt1vJ6hVFVus5xwVYvggf90gvI7tD1jgx49+/biK9duAI+YJBK0G J54xGlwPDJ+6FzRub4WQRHlxqXpXOIsOWO23sEYKZMFtsaTYxLgBox/a7glLenCiQGpN Tio+2qIHeZUgxb1jCBfbpC6R1ESSLEIdpC1uMFbAfjbZbQQYJkdOp32cR2TDgKNCXeZl gzClLI+dGXD2jLbVB7ENUi1bqI+dkAyhUWizgKt1aBX2q4y56tH2i4ovXEc+A+G2cu5D cbT9wCgiRbwVVSfdP3KoLqzeLHTqHY+nTTnmugaBmG3MEP2c3Ju5blw48CUK87EyIKKr 5qWA== 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=NXgqaTe7MzaXWf5UCSOBEWEUXIZMj00LRl/OCoFVpiQ=; b=USAgDPHDgI+9PPTfD3y7yE6Qurk9ZuVJ7Hmc/LZLML8xN+ekkr1MPW2zmaB5tfsc0Q uXzRlL1A5MYI/N4skuHi9vNCUAOiZaSHxtvTFUjvakOMQ5+xR/42jIrYeTngtB5dogak tRXY52eb4Q3TnS/hpQjUJ4+lAbSE+4G9lIC5NucO/VSw6E/mDdzBrp6W8l8LQVJ2Xm0y TUHU4pX6UlBmYkpHit3j1RrALu0i2Ydzz00RXtPJrKzXmwLr9W3guu5g04FPZLyZ/eJf bARhATVvF3M/JR/C5vU/t3ZShXDdh7RyosdG6Ll8mV3xtOrt60lum4h6+X5SUCtaTsfE SKAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P1RhRRGN; 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.44; Tue, 28 Aug 2018 13:13:44 -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=P1RhRRGN; 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 S1727104AbeH2AG6 (ORCPT + 13 others); Tue, 28 Aug 2018 20:06:58 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:44521 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726961AbeH2AG6 (ORCPT ); Tue, 28 Aug 2018 20:06:58 -0400 Received: by mail-pl1-f194.google.com with SMTP id ba4-v6so1195711plb.11 for ; Tue, 28 Aug 2018 13:13:43 -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=NXgqaTe7MzaXWf5UCSOBEWEUXIZMj00LRl/OCoFVpiQ=; b=P1RhRRGNgEF0EFv8KeZpXvlzy85Lqi2EHv1y8fSZAjxIepSxvmFEKbL8tuUI9khPvc /5hOklkclEjNW+C2RAGyihzjYX3zO1Np4mon2c2XyVGxU9GJRHIhTTQxcWBspMI6LQD0 n6/rZmp5Wh2bbn5kpSGC7fszsF0L3LM58B8gk= 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=NXgqaTe7MzaXWf5UCSOBEWEUXIZMj00LRl/OCoFVpiQ=; b=GnZ8XHNsLoleZp1DL7J6F3Axd2y0aZrCUeu3J0fxMXA6S31YYJgmTI52w4EHkdWSBB 0e67YpzoaNqFRE0+jrKytrql1lFtTGBHKejjcRWiGLmhYpqXVUXs+dPXJyvz5Jcmqy6a 9auWOu52N6WPGGWN2yhMtNbmQyXk7ov38h75k1lP4n9iQJvrc242y0n0LbGEvH1r/kcg cT1/ESkH7AfYBYggCJ89Y5pdKeKBPKRf7EdkXtvofY3mZnKbLzNiJYu17/SdeabuU54U PoA7xzlpTLzb1aJec3uBhlGdErBvrArDwYXhsdRovlt+fLIxvN/iDPzVzCPjX+TOMgn5 VE3Q== X-Gm-Message-State: APzg51DaJJxfmrCuwcn/tny8iSASReEXFfh0eyDINm8VLj1KZQBWqCIs Z4jMMbLGPoezT810zyq6Q4ji+w== X-Received: by 2002:a17:902:850c:: with SMTP id bj12-v6mr2987043plb.330.1535487223130; Tue, 28 Aug 2018 13:13:43 -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.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Aug 2018 13:13:41 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , "Jason A. Donenfeld" , Theodore Ts'o Subject: [PATCH for-4.9.y 04/14] random: convert get_random_int/long into get_random_u32/u64 Date: Wed, 29 Aug 2018 01:43:15 +0530 Message-Id: <1535487205-26280-5-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: "Jason A. Donenfeld" commit c440408cf6901eeb2c09563397e24a9097907078 upstream. Many times, when a user wants a random number, he wants a random number of a guaranteed size. So, thinking of get_random_int and get_random_long in terms of get_random_u32 and get_random_u64 makes it much easier to achieve this. It also makes the code simpler. On 32-bit platforms, get_random_int and get_random_long are both aliased to get_random_u32. On 64-bit platforms, int->u32 and long->u64. Signed-off-by: Jason A. Donenfeld Cc: Greg Kroah-Hartman Cc: Theodore Ts'o Signed-off-by: Theodore Ts'o Signed-off-by: Amit Pundir --- drivers/char/random.c | 55 +++++++++++++++++++++++++------------------------- include/linux/random.h | 17 ++++++++++++++-- 2 files changed, 42 insertions(+), 30 deletions(-) -- 2.7.4 diff --git a/drivers/char/random.c b/drivers/char/random.c index 81b65d0e7563..464b95a63dc5 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -2110,8 +2110,8 @@ struct ctl_table random_table[] = { struct batched_entropy { union { - unsigned long entropy_long[CHACHA20_BLOCK_SIZE / sizeof(unsigned long)]; - unsigned int entropy_int[CHACHA20_BLOCK_SIZE / sizeof(unsigned int)]; + u64 entropy_u64[CHACHA20_BLOCK_SIZE / sizeof(u64)]; + u32 entropy_u32[CHACHA20_BLOCK_SIZE / sizeof(u32)]; }; unsigned int position; }; @@ -2121,52 +2121,51 @@ struct batched_entropy { * number is either as good as RDRAND or as good as /dev/urandom, with the * goal of being quite fast and not depleting entropy. */ -static DEFINE_PER_CPU(struct batched_entropy, batched_entropy_long); -unsigned long get_random_long(void) +static DEFINE_PER_CPU(struct batched_entropy, batched_entropy_u64); +u64 get_random_u64(void) { - unsigned long ret; + u64 ret; struct batched_entropy *batch; - if (arch_get_random_long(&ret)) +#if BITS_PER_LONG == 64 + if (arch_get_random_long((unsigned long *)&ret)) return ret; +#else + if (arch_get_random_long((unsigned long *)&ret) && + arch_get_random_long((unsigned long *)&ret + 1)) + return ret; +#endif - batch = &get_cpu_var(batched_entropy_long); - if (batch->position % ARRAY_SIZE(batch->entropy_long) == 0) { - extract_crng((u8 *)batch->entropy_long); + batch = &get_cpu_var(batched_entropy_u64); + if (batch->position % ARRAY_SIZE(batch->entropy_u64) == 0) { + extract_crng((u8 *)batch->entropy_u64); batch->position = 0; } - ret = batch->entropy_long[batch->position++]; - put_cpu_var(batched_entropy_long); + ret = batch->entropy_u64[batch->position++]; + put_cpu_var(batched_entropy_u64); return ret; } -EXPORT_SYMBOL(get_random_long); +EXPORT_SYMBOL(get_random_u64); -#if BITS_PER_LONG == 32 -unsigned int get_random_int(void) -{ - return get_random_long(); -} -#else -static DEFINE_PER_CPU(struct batched_entropy, batched_entropy_int); -unsigned int get_random_int(void) +static DEFINE_PER_CPU(struct batched_entropy, batched_entropy_u32); +u32 get_random_u32(void) { - unsigned int ret; + u32 ret; struct batched_entropy *batch; if (arch_get_random_int(&ret)) return ret; - batch = &get_cpu_var(batched_entropy_int); - if (batch->position % ARRAY_SIZE(batch->entropy_int) == 0) { - extract_crng((u8 *)batch->entropy_int); + batch = &get_cpu_var(batched_entropy_u32); + if (batch->position % ARRAY_SIZE(batch->entropy_u32) == 0) { + extract_crng((u8 *)batch->entropy_u32); batch->position = 0; } - ret = batch->entropy_int[batch->position++]; - put_cpu_var(batched_entropy_int); + ret = batch->entropy_u32[batch->position++]; + put_cpu_var(batched_entropy_u32); return ret; } -#endif -EXPORT_SYMBOL(get_random_int); +EXPORT_SYMBOL(get_random_u32); /** * randomize_page - Generate a random, page aligned address diff --git a/include/linux/random.h b/include/linux/random.h index 16ab429735a7..ed5c3838780d 100644 --- a/include/linux/random.h +++ b/include/linux/random.h @@ -42,8 +42,21 @@ extern void get_random_bytes_arch(void *buf, int nbytes); extern const struct file_operations random_fops, urandom_fops; #endif -unsigned int get_random_int(void); -unsigned long get_random_long(void); +u32 get_random_u32(void); +u64 get_random_u64(void); +static inline unsigned int get_random_int(void) +{ + return get_random_u32(); +} +static inline unsigned long get_random_long(void) +{ +#if BITS_PER_LONG == 64 + return get_random_u64(); +#else + return get_random_u32(); +#endif +} + unsigned long randomize_page(unsigned long start, unsigned long range); u32 prandom_u32(void); From patchwork Tue Aug 28 20:13:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 145361 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1589177ljw; Tue, 28 Aug 2018 13:13:47 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb11lc7mGhw7+GUMvGCz1EazfC90umFkGevVn/cASeB9RVEFcvSrpKgAB0OEc27vZ2CULoM X-Received: by 2002:a62:34c4:: with SMTP id b187-v6mr2944208pfa.15.1535487227308; Tue, 28 Aug 2018 13:13:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535487227; cv=none; d=google.com; s=arc-20160816; b=zNWQIaMbyILG59sZej7bX8q/ttAbb3K3t4QjihBbo/Ck2LcBNV3bRUvQky0YEpO981 sz647ja8N8IPujZeKTwRNonAGVEuYJwWJviUPaxRrPMfyV3c8Wr6uis6hxgLlNMSeuVU 67+bX9wiK+d23zvO+kPjmIYQLNy+6vNWqMwzwAZbD3BMs7jRKGZGY45z8IQCH87tOy8n ov7pHJ0BID9ynGq4LlPEpyqqtl7iHpRuss+hC4a+nDRChsyNBqV2jEJ7qGCIEDecSHTi QlV+f7Bf7teswf8iHgy7Bm7FOmCmjxTdsf1TE/MbKiubkeYPeJbln/vaf6zNCLUCl42C qd3g== 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=qYcf063hllozIk+Vm2lQwN4IeBSGRsR7ZzxbTQ78qI8=; b=rkJp6dJoyDDjodTz0UedZtmqHZQDRlu8Dg5GtqnQwO8pwLr4bZu1a/b9C2pvyvK767 7SorfFSNK7fqjsoeE+nJtTKRrriA9Omo+4RIq/VEj3W6LDPRW8GfCKrtYqua5ANSEhUX csULS1S7sVs1R1kVvxCeLG25ravVWtkN5rYeCebWOTmRQkBJ4e9Bu9rzcft2gcsnjEr0 thdczcR873oEcOotlW7vJxDv5frp1/8kx0yjcPYMin8ctQ45g94yCZEGrKSBzuKndoZJ UzzV5TJvVGcvSRY0b0AWku0yRdj7/dpU7mynKsdndEsYzHS6fkAX/7w/dQbscElF+R9I xwRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CoqLLGf4; 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.47; Tue, 28 Aug 2018 13:13:47 -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=CoqLLGf4; 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 S1727117AbeH2AHA (ORCPT + 13 others); Tue, 28 Aug 2018 20:07:00 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:37238 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726961AbeH2AHA (ORCPT ); Tue, 28 Aug 2018 20:07:00 -0400 Received: by mail-pg1-f194.google.com with SMTP id 2-v6so717256pgo.4 for ; Tue, 28 Aug 2018 13:13:46 -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=qYcf063hllozIk+Vm2lQwN4IeBSGRsR7ZzxbTQ78qI8=; b=CoqLLGf4dUyq+m6cSA8vBJS6VFkhspOmBcbqIFv3eYACETEqV8ByMw+Ca+/iCHF7lH z8lpDc9UsldOv6iKWtGDdzLC5x6g5lbzW4PmkyPvD4qkjtOYqfID4E0lwALl6lXY1Eq8 wRHOWXu0IlHPkW18QhkMVGx8CclDpet97fwKc= 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=qYcf063hllozIk+Vm2lQwN4IeBSGRsR7ZzxbTQ78qI8=; b=FoDHryfQVXylsRtpum0U0s+ocuocSUAJoOylK/pm2OCF1Ca6AZ/vZq9GzEhSQPMW5G QL6Hk0MkzhF+Yl/psQSBr7i1UNk0/67AWALtoNyrGECllO2BwvgzcyT+b1RbVFH6fCS5 c6LxBNBnB8/EyHbP7G0/OWJmp8WVrMC6MKEB0tTpbLUzeAstI/+YkhPLw47FoFkcbc8N DmRjGjpvco6UYtc/sdjsqW6w1sGAJ7Sk30F0chGX/DmF3u9Gf+0GudSip7Mb+CWfYdqy dcJ+32GF4EIh6RKRR+CwUvsuYJv8ZUrKXdfpta0BaAZggHimwQNYVK4NHbjgoH6m/AnE LMsg== X-Gm-Message-State: APzg51Anni2Am0CWkRZNuBBxv8BA2i9S/rEsl/AFKLD5/GSyNwUtxNbD 6kaoHC44fMa4nm+mwle8S+5bRA== X-Received: by 2002:a62:cc41:: with SMTP id a62-v6mr2948242pfg.131.1535487225629; Tue, 28 Aug 2018 13:13:45 -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.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Aug 2018 13:13:44 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Jia-Ju Bai Subject: [PATCH for-4.9.y 05/14] staging: rt5208: Fix a sleep-in-atomic bug in xd_copy_page Date: Wed, 29 Aug 2018 01:43:16 +0530 Message-Id: <1535487205-26280-6-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: Jia-Ju Bai commit 498c4b4e9c23855d17ecc2a108d949bb68020481 upstream. The driver may sleep under a spin lock, and the function call path is: rtsx_exclusive_enter_ss (acquire the lock by spin_lock) rtsx_enter_ss rtsx_power_off_card xd_cleanup_work xd_delay_write xd_finish_write xd_copy_page wait_timeout schedule_timeout --> may sleep To fix it, "wait_timeout" is replaced with mdelay in xd_copy_page. Signed-off-by: Jia-Ju Bai Signed-off-by: Greg Kroah-Hartman 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. drivers/staging/rts5208/xd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/staging/rts5208/xd.c b/drivers/staging/rts5208/xd.c index 1de02bb98839..647f6beb4c65 100644 --- a/drivers/staging/rts5208/xd.c +++ b/drivers/staging/rts5208/xd.c @@ -1247,7 +1247,7 @@ static int xd_copy_page(struct rtsx_chip *chip, u32 old_blk, u32 new_blk, reg = 0; rtsx_read_register(chip, XD_CTL, ®); if (reg & (XD_ECC1_ERROR | XD_ECC2_ERROR)) { - wait_timeout(100); + mdelay(100); if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) { From patchwork Tue Aug 28 20:13:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 145362 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1589230ljw; Tue, 28 Aug 2018 13:13:50 -0700 (PDT) X-Google-Smtp-Source: ANB0VdasEIYRMLpALU+yISykAbxikNxt6Wo2hKioeE2XPvrpDcSaxE9ClugUj++sGVuXRSKv1ach X-Received: by 2002:a65:520d:: with SMTP id o13-v6mr2942512pgp.282.1535487230014; Tue, 28 Aug 2018 13:13:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535487230; cv=none; d=google.com; s=arc-20160816; b=O/3wj2cr/Qovl+bmuqqIMBpGfJ5cGEvq/E8rGOv3ZViLM/x77EtLFQ1cJnaUWTfObC TYDm92rDKvFZLuq4doLVI7vrb/v/aZCp8+sLvpesupPpDs7btu5bKHBbpnuiTZ2J+GK1 LQLlbJwLLGXx0V6b7EsKDaXiJeOa1p6Nc1LAqsoS4+bT71XWjXNXihdeWAUPO5fUHUpS pjyNNj0sOsBp5Ej93Ja+lLcKSOwM62UpdrUFmsyZNqZ3cbIkWCNQxh574uk5uHWga64j zDmJKU5Z6Kohy9eOB8U/bK+R1ZUuWHV1wx8yGsrInrNDIZnzQOZZzqFZrsfBnCCq6lrm qhgA== 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=TXw3P4FPYZd2psDcpNo0aDwlZC4DOHZgU3cnNo2rc6w=; b=W3cZCrHsmC3e6gkABTqVFrOPQw9U7DcW1bR9HGILn2yo7YO3lUyM1jZDUhTDql4qkf MePuybjvrAqbmIf+UPaLS6WmHkliUyFbXeZldikI9U0C3FYnFGczDyoPHMXmZDOLBRTE E5N+Gjsy1/Er0Ze8x/yt0KB4X6sv8OEft6gyBLDerCdpxJCjC9NwcTwQNrZ9kya3K2bp jJl/mCSiJrO9ZD7T9nJn0kwqqQCsO8U2SiVGPaBdQ5h5DkF3YFPcckVdl51nKO/07TMe HFFdeeMxeIkibcN91JgYFwOUHhHQAyvHT5tK0xqWhaPKCaElczBxYbEP/mnJHPTHXSoR H1nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LdrzLcdM; 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.49; Tue, 28 Aug 2018 13:13:50 -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=LdrzLcdM; 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 S1727144AbeH2AHD (ORCPT + 13 others); Tue, 28 Aug 2018 20:07:03 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:35292 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726961AbeH2AHD (ORCPT ); Tue, 28 Aug 2018 20:07:03 -0400 Received: by mail-pg1-f195.google.com with SMTP id z4-v6so1248625pgv.2 for ; Tue, 28 Aug 2018 13:13:48 -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=TXw3P4FPYZd2psDcpNo0aDwlZC4DOHZgU3cnNo2rc6w=; b=LdrzLcdMZI7pJeR5aV17wXIdAWEI6KhV5MN2n3u8U0UiR1ZeIrS3ZkPisGpooTzv6V VM7NIEMdz1/0KBNPTvGj6P7zSZHkvkkPH3+rwc9SB90x46eBSHBxcwPnlNsNKA3cC5ko 96VsT5Lxwn18xk5dKQsACiVQMmskbp4hd64kg= 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=TXw3P4FPYZd2psDcpNo0aDwlZC4DOHZgU3cnNo2rc6w=; b=IGU29QIWAr7HB4Al7AOgAT6BgRlfiGuD0ErqDeMftmj/XDq8ou1kHqTGzFmNSZxkiH AMxFc0RDHGDeaW+FXbUZDQc/z05gR22pnr0yjnfH7McNSmlCsmfocguq798+FSioTspT Gch093AEfIj0ll5txGs5Hm0ICQ93ctG6Vy6s2pbGSd3ZYXvck3nyHGOwyVR22mFbCuqV bvgJDgjmJrfl4xk6v9wIFxn4cD1OV+fps86yB6FiOftdwpOuPxlbLMifi4BNX21PI+hM BtkNnT0UgshOI7g0xGaFSKSR03QzqsZ11oD0GNOrnren1Ym8qCtifKCfCDidaEaTFqns gKwQ== X-Gm-Message-State: APzg51D3xQFvCqj1Xqus4TeQk67b/YbFVLQZlUVgH/IXAoJtCNG1HPvd gfKoRiC3zmuMD1pVwAuvICyu4Q== X-Received: by 2002:a63:5fc8:: with SMTP id t191-v6mr2886716pgb.183.1535487228559; Tue, 28 Aug 2018 13:13:48 -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.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Aug 2018 13:13:47 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Daniel Micay , Kees Cook , Wayne Porter Subject: [PATCH for-4.9.y 06/14] staging/rts5208: Fix read overflow in memcpy Date: Wed, 29 Aug 2018 01:43:17 +0530 Message-Id: <1535487205-26280-7-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: Daniel Micay commit 88a5b39b69ab1828fd4130e2baadd184109cea69 upstream. Noticed by FORTIFY_SOURCE, this swaps memcpy() for strncpy() to zero-value fill the end of the buffer instead of over-reading a string from .rodata. Signed-off-by: Daniel Micay [kees: wrote commit log] Signed-off-by: Kees Cook Cc: Greg Kroah-Hartman Cc: Wayne Porter Signed-off-by: Greg Kroah-Hartman 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. drivers/staging/rts5208/rtsx_scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/staging/rts5208/rtsx_scsi.c b/drivers/staging/rts5208/rtsx_scsi.c index b3790334fd3f..f50076d0fb6c 100644 --- a/drivers/staging/rts5208/rtsx_scsi.c +++ b/drivers/staging/rts5208/rtsx_scsi.c @@ -536,7 +536,7 @@ static int inquiry(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (sendbytes > 8) { memcpy(buf, inquiry_buf, 8); - memcpy(buf + 8, inquiry_string, sendbytes - 8); + strncpy(buf + 8, inquiry_string, sendbytes - 8); if (pro_formatter_flag) { /* Additional Length */ buf[4] = 0x33; From patchwork Tue Aug 28 20:13:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 145363 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1589273ljw; Tue, 28 Aug 2018 13:13:53 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYczr/PT2+mzZ2+bnBJeVmUsyIhCpdBezOeaT5EBFwuL0rCH7g1GxKi6aAh7hyEiQ5DAdZV X-Received: by 2002:a17:902:c7:: with SMTP id a65-v6mr2966170pla.208.1535487233680; Tue, 28 Aug 2018 13:13:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535487233; cv=none; d=google.com; s=arc-20160816; b=TnVvD8+g5DFnrJl4QQsYokkbZeLSi4cIGjuscLu5SBaSSk265PHaWCcDD9mBY4rk9y xXnJwsQOjXqjyYk0bz9sDluyyUbolTMoOoTS/4qbh06jZwrlK6H03/VGs6gGw4Puyvua 5Br+wyHcrr2IjhPOvHfVXh0fNEybVyPakn1ASKOW+IK6mEW2VDYo5rEtAAvwMQqKpPGs ax/uG5QyKQYGuSvNlOYTibFXi0yvIL13SumzpCXiFUmQ4Zh53ejx9QU+Obz1GXFuYL4d h7NXjepBU17rKd4r5tHfvKvZHhvpJMMYAre0oaMfGkDzLa12FIaIVXxp96sMb/BaT+nw vrkw== 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=hToHjQhxx57Un6iIdORQSqGREQp5tZKVO/POgiXPljM=; b=zMYssOcvcu+twWXiXpq2rUUruYzGrUy/b+o3rpQn2f3OCbp9FVqfL3t8UVE8KyMMdF ONIKkXTVvSqAdDS5GU355qekp1in4eVXjojl7UjhahANhZ4d0DAllLSSD/tY5Sxb4KFr tWsD9u0w+7TZNy7WKsWHNBbutJmy5g3tKbP/mzCFx/MBi1LmJswJLYs1esV7BJfzqymm ZrbvMV+8LuGraRtqGyj95XK96QgJOS767idMuJzufcAPuiIZJnglyDl/M9iKEUswmr+T 6eIPnSYl/wGWoy0oZOyvmgfRIpH38Gc5hZeE+FYN6Axut7iqHcJFVZqgQ9eRFalnIN+R +MRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Z/mMou/9"; 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.53; Tue, 28 Aug 2018 13:13:53 -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="Z/mMou/9"; 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 S1727146AbeH2AHH (ORCPT + 13 others); Tue, 28 Aug 2018 20:07:07 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:33544 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726961AbeH2AHG (ORCPT ); Tue, 28 Aug 2018 20:07:06 -0400 Received: by mail-pl1-f193.google.com with SMTP id 60-v6so1216969ple.0 for ; Tue, 28 Aug 2018 13:13:52 -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=hToHjQhxx57Un6iIdORQSqGREQp5tZKVO/POgiXPljM=; b=Z/mMou/97vZvgZspP36Tn5Zr2ZXD8xjvnePHMhNnFfEA0xRHEqardXT+dJEPQ1mc+N e2DzNQUEZYLk2mxOcZaE7YAhE2feWyk/gP0yhh3U+4MvBVH3FaC4QHobg7VhpNmaTMER xm5HkU6+2rE23Sl2NjEs8g/aD63W0fE2CRqRA= 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=hToHjQhxx57Un6iIdORQSqGREQp5tZKVO/POgiXPljM=; b=jP0a+IsjfwPEYZeh2JVu7FBWZA4uTFiJSeWH3TB19EP9blu/LS4Cq4vEGEgKPmlVNi eiV7ewv/sVruPZF/bg0fw12GWcG1HfxpS30ZwCBBIevWKpPl5wr/Z/AI2ry9QwlHZxdh Gstw6fj3ISnyED2lrC3DcozOWuO6JeV9qqeoQ+VLzStruiEWyGvpJVr4ofKhZjlmeDhN x8UREv36g1aoXZbpFeq/HXTwhgAbU5dmerR4RBnZqucIOJEnDvZs8Hcynh+T0UI/moXG 9r2Mn2lZdCr/6swofzCZriTLoMtbG/T6sGlhQhb44AQgls4c+5yLEo1x/r8A4k3AMPNW 1h3A== X-Gm-Message-State: APzg51CyjEnMrB3cfu83bmaFdz04Ih2WCzeCnupSnmgS+1YkfUZEcypd W4Q5HVYrRViDL8rorXCXjwC2WQ== X-Received: by 2002:a17:902:6681:: with SMTP id e1-v6mr2926321plk.109.1535487232280; Tue, 28 Aug 2018 13:13:52 -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.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Aug 2018 13:13:51 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Kees Cook , Moni Shoua , Doug Ledford , Sean Hefty , Daniel Micay , Andrew Morton , Linus Torvalds Subject: [PATCH for-4.9.y 07/14] IB/rxe: do not copy extra stack memory to skb Date: Wed, 29 Aug 2018 01:43:18 +0530 Message-Id: <1535487205-26280-8-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: Kees Cook commit 4c93496f18ce5044d78e4f7f9e018682a4f44b3d upstream. This fixes a over-read condition detected by FORTIFY_SOURCE for this line: memcpy(SKB_TO_PKT(skb), &ack_pkt, sizeof(skb->cb)); The error was: In file included from ./include/linux/bitmap.h:8:0, from ./include/linux/cpumask.h:11, from ./include/linux/mm_types_task.h:13, from ./include/linux/mm_types.h:4, from ./include/linux/kmemcheck.h:4, from ./include/linux/skbuff.h:18, from drivers/infiniband/sw/rxe/rxe_resp.c:34: In function 'memcpy', inlined from 'send_atomic_ack.constprop' at drivers/infiniband/sw/rxe/rxe_resp.c:998:2, inlined from 'acknowledge' at drivers/infiniband/sw/rxe/rxe_resp.c:1026:3, inlined from 'rxe_responder' at drivers/infiniband/sw/rxe/rxe_resp.c:1286:10: ./include/linux/string.h:309:4: error: call to '__read_overflow2' declared with attribute error: detected read beyond size of object passed as 2nd parameter __read_overflow2(); Daniel Micay noted that struct rxe_pkt_info is 32 bytes on 32-bit architectures, but skb->cb is still 64. The memcpy() over-reads 32 bytes. This fixes it by zeroing the unused bytes in skb->cb. Link: http://lkml.kernel.org/r/1497903987-21002-5-git-send-email-keescook@chromium.org Signed-off-by: Kees Cook Cc: Moni Shoua Cc: Doug Ledford Cc: Sean Hefty Cc: Daniel Micay Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Amit Pundir --- drivers/infiniband/sw/rxe/rxe_resp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c index 0d25dc84d294..2152c71a99d3 100644 --- a/drivers/infiniband/sw/rxe/rxe_resp.c +++ b/drivers/infiniband/sw/rxe/rxe_resp.c @@ -978,7 +978,9 @@ static int send_atomic_ack(struct rxe_qp *qp, struct rxe_pkt_info *pkt, free_rd_atomic_resource(qp, res); rxe_advance_resp_resource(qp); - memcpy(SKB_TO_PKT(skb), &ack_pkt, sizeof(skb->cb)); + memcpy(SKB_TO_PKT(skb), &ack_pkt, sizeof(ack_pkt)); + memset((unsigned char *)SKB_TO_PKT(skb) + sizeof(ack_pkt), 0, + sizeof(skb->cb) - sizeof(ack_pkt)); res->type = RXE_ATOMIC_MASK; res->atomic.skb = skb; From patchwork Tue Aug 28 20:13:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 145364 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1589305ljw; Tue, 28 Aug 2018 13:13:56 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaJSp85+BRBqmcMjZhzu0AHhFKMW8n8CtRKa5owfvB3rRgZ9+F5/T4O0lm3ivpPTSbhZo3h X-Received: by 2002:a17:902:1025:: with SMTP id b34-v6mr2941469pla.291.1535487236553; Tue, 28 Aug 2018 13:13:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535487236; cv=none; d=google.com; s=arc-20160816; b=srBxmMdhg5cTtsnfI9BWP+Aygu3Z5ytfB7/yvEwpiiVtfwZqficy7AVaNHS/iJDCHj myYAoDbEySfsD9DrULUKf9n9Xax9OpeyWAvF0JLNbxjgXhMRxGHpOvjC1hwfY5WrOD/U olSQY0GY4pzzXC/Zd0mw2Xc1VD2rIiNIU95I04w5nMAP91SpR4WjoxWmI2aq3K9V/OZl GOv1XfZeY2BLhSSLOOlNf0Q8pCpqbJyMZemWswWCnJYECy0vl9B5tvNahF//lLHlW7K5 WOQ9rLKYQGM0kckMXw3imbQI2DgdHCV+bCG4M90k7pNb8vs5qjMIATm9CPqxYz0gYDo4 8iAg== 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=5BJrgdZSmdKlPX4RPaS1C+BNPd9RzMdGtWKF+5j30P4=; b=Ij2BX+cnhhEXjDKbLTxhEYU5e2vzwgBDJ6Svjel1vwYvKzxGarZanAYEU4raT2qnSv WAg3CJTX6fc2rn5y/HzVu1d6TyJCdPzwPpjW4f9cIWrDRXiiSbQC7foJQquyqpz18X7U 0RM0jT88vPuS4NEuKhOqDoVHyrWwIBda7CROiYu7vE0MUyED0KKbkLcYvL9FJTdEJQ2T Yp/VBZk4trbSgpysK7s96CFUcVD75JgjB8oMGXmMbHrj3c0vdVtG9Mj9baXuuO4Q8Qk9 8uBymyXG3VIng8yLCPNyRAgvpJd8dVKxUs7Lf2Z+3Mhm9uIrC7EYYm1KiKSTDcWJTzZk PohQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ymj2RWyL; 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.56; Tue, 28 Aug 2018 13:13:56 -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=Ymj2RWyL; 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 S1727166AbeH2AHJ (ORCPT + 13 others); Tue, 28 Aug 2018 20:07:09 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:44534 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726961AbeH2AHJ (ORCPT ); Tue, 28 Aug 2018 20:07:09 -0400 Received: by mail-pl1-f196.google.com with SMTP id ba4-v6so1195948plb.11 for ; Tue, 28 Aug 2018 13:13:55 -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=5BJrgdZSmdKlPX4RPaS1C+BNPd9RzMdGtWKF+5j30P4=; b=Ymj2RWyLp/DKzB0X6duIV3ZI+xX6OQqQoPfWD0hiVFke5zvwHbwfojiYH9RyiJzF7n AR6qEi2YOvh/tPNsZ3pGitxxCStbhn2oPJB/FYHsqUjdA+/nn2YI4jsY7Y6xaW9KJGkJ AfGieoGDjF3UZ9lpXgR7080T+Y/sQXYHziQ8M= 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=5BJrgdZSmdKlPX4RPaS1C+BNPd9RzMdGtWKF+5j30P4=; b=G+VicP6KMIswVHl+814Lq35d98c+jMYAVZYZGaZIZq5PpSAZAgoMMnxRjGw5sWgPSS qbTsV/jeh7vRFXSp5fi3WaM34enIdGzS0fD1oYs0W9VwnM3k/d7Ir32P70as/tfVGn87 qRb+7syhvTNpUyI87t8hGwSmOLpBWS2Ojl/1njZpKio58WKW+nat8Jh1sgJQ4e6haVPl vjHtDQdGNjoVEGwXmsjQMKvv4ei7f3YSvr/kJFsPK5kZy1A9KpzOEJRh0ICTd1uS8Lue YSn3Lne6/RAVpC4Fu3q5QWhuMC3Jj2VkjMB9q+VlqSHHYDQ+ZZPfx5yJNPoS+M4J86AF wV0Q== X-Gm-Message-State: APzg51CR4wFTGuxCG8s0myhijg5RumFgl8b9XmCPhNGnT8omyktVNF8y /aD+QoKeDyatTL6PkfjfoXrQXg== X-Received: by 2002:a17:902:4e:: with SMTP id 72-v6mr2908935pla.318.1535487235066; Tue, 28 Aug 2018 13:13:55 -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.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Aug 2018 13:13:53 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Tejun Heo , Jens Axboe Subject: [PATCH for-4.9.y 08/14] block, blkcg: use __GFP_NOWARN for best-effort allocations in blkcg Date: Wed, 29 Aug 2018 01:43:19 +0530 Message-Id: <1535487205-26280-9-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: Tejun Heo commit e00f4f4d0ff7e13b9115428a245b49108d625f09 upstream. blkcg allocates some per-cgroup data structures with GFP_NOWAIT and when that fails falls back to operations which aren't specific to the cgroup. Occassional failures are expected under pressure and falling back to non-cgroup operation is the right thing to do. Unfortunately, I forgot to add __GFP_NOWARN to these allocations and these expected failures end up creating a lot of noise. Add __GFP_NOWARN. Signed-off-by: Tejun Heo Reported-by: Marc MERLIN Reported-by: Vlastimil Babka Signed-off-by: Jens Axboe Signed-off-by: Amit Pundir --- To be applied on 4.4.y as well. Build tested on v4.4.153. block/blk-cgroup.c | 9 +++++---- block/cfq-iosched.c | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 6cd839c1f507..f570f387034d 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -185,7 +185,8 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg, } wb_congested = wb_congested_get_create(&q->backing_dev_info, - blkcg->css.id, GFP_NOWAIT); + blkcg->css.id, + GFP_NOWAIT | __GFP_NOWARN); if (!wb_congested) { ret = -ENOMEM; goto err_put_css; @@ -193,7 +194,7 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg, /* allocate */ if (!new_blkg) { - new_blkg = blkg_alloc(blkcg, q, GFP_NOWAIT); + new_blkg = blkg_alloc(blkcg, q, GFP_NOWAIT | __GFP_NOWARN); if (unlikely(!new_blkg)) { ret = -ENOMEM; goto err_put_congested; @@ -1022,7 +1023,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css) } spin_lock_init(&blkcg->lock); - INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_NOWAIT); + INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_NOWAIT | __GFP_NOWARN); INIT_HLIST_HEAD(&blkcg->blkg_list); #ifdef CONFIG_CGROUP_WRITEBACK INIT_LIST_HEAD(&blkcg->cgwb_list); @@ -1238,7 +1239,7 @@ int blkcg_activate_policy(struct request_queue *q, if (blkg->pd[pol->plid]) continue; - pd = pol->pd_alloc_fn(GFP_NOWAIT, q->node); + pd = pol->pd_alloc_fn(GFP_NOWAIT | __GFP_NOWARN, q->node); if (!pd) swap(pd, pd_prealloc); if (!pd) { diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index b2dc1c1f08c6..a4e2d0104af4 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c @@ -3868,7 +3868,8 @@ cfq_get_queue(struct cfq_data *cfqd, bool is_sync, struct cfq_io_cq *cic, goto out; } - cfqq = kmem_cache_alloc_node(cfq_pool, GFP_NOWAIT | __GFP_ZERO, + cfqq = kmem_cache_alloc_node(cfq_pool, + GFP_NOWAIT | __GFP_ZERO | __GFP_NOWARN, cfqd->queue->node); if (!cfqq) { cfqq = &cfqd->oom_cfqq; From patchwork Tue Aug 28 20:13:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 145365 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1589330ljw; Tue, 28 Aug 2018 13:13:59 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY6uJAERO/GXgeK6Wr6DKzXDqkrTu9V/C6tY7dx25HWVOhPcskiYpKS7kBjuvZPG0qMqwdL X-Received: by 2002:a63:24c:: with SMTP id 73-v6mr2999809pgc.252.1535487238932; Tue, 28 Aug 2018 13:13:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535487238; cv=none; d=google.com; s=arc-20160816; b=gRPdfwueoEkdwBlYXpH5tORJwZ8qOtUp1nXtYbL5ahcEJiSagGo3AtOpFtM9K0QESO r+dh8Hgl+jof7Yh9VZNGvQxOIHEYCCbsirew7r8D0t+EaozJMshM99qVlJITvd/vI4LS Bhfjxsk6Gzt68gfwG/0uNe3aQ9ziSKW8sl9mAPwt8D6eCcFtGf8ctNjbRASeyhlc18T+ ptC6veA5hgqevwWanfE9my7fcowqIA9kAjOr0cirbzui6o0Tno9OeRSjEbPJXe7emJNo oqYSJy/87/Xp7OV+n0UpjxdD8oNBJ+Yj4y4jVqAE9ld1MLVszc6XjYknoPgftZjdET6H jEnQ== 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=5Wx3Vk+m13O+tLb6eC1+vGJ7O1A2F6aM7GY1IjybIn8=; b=A1AOEEkQL42sSn3Nfyw7RA6krT8jmXGxJlqUUczybl2k5vB6B2hB6+2Tw5mb/VYCGK sguYdctAy7CHBkWqDAlXloMQZm6ocBfk24oJDH9Wq69R6xDQPDHUoYR6NWIcIsAsCOnn S/8MMwTPmCEBFNb1kfYaIlQRhzCjukPxsTrAqJDJMmkQsVdbJ9G5L8gP3/8i7ZqxP5vg VtoMC4XSpjnj9nr3KZ5NK66zKVFXhAAgruXLTCNGwCuTMrqiTeD4X3SkWd5MsFiamXAF dn7q6kkpRuBNKBAiWWHAsla4VQEpbD/wAkUec6Z0yj5oxGAAaVDSyhh+cChVrWAIZiCn j/oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=glSFnYJG; 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.58; Tue, 28 Aug 2018 13:13:58 -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=glSFnYJG; 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 S1727178AbeH2AHM (ORCPT + 13 others); Tue, 28 Aug 2018 20:07:12 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:36542 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726961AbeH2AHM (ORCPT ); Tue, 28 Aug 2018 20:07:12 -0400 Received: by mail-pl1-f195.google.com with SMTP id e11-v6so1210867plb.3 for ; Tue, 28 Aug 2018 13:13:57 -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=5Wx3Vk+m13O+tLb6eC1+vGJ7O1A2F6aM7GY1IjybIn8=; b=glSFnYJGI+bAS4+2Gzjq0noD2/dYK8BXJ9a/v3rQOoydnur+GO9qvmLE9Ff/o5SmlW 2p+UlgxO+J9/h4jVzvHtQi/Y4h6ag+b0YMmLdGM8/fbL9/KUpRsxnuhIKh6WAxHrmD0P YvEdzeFH1OjI2KCkogcWNJYMAZc1jZWg7YwCo= 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=5Wx3Vk+m13O+tLb6eC1+vGJ7O1A2F6aM7GY1IjybIn8=; b=Sgf+Riu0knXvR98lcgo4PnQv5aLhndNEDKOlByZGvQit0omfk9XNIeNz0KFVQQKnRE pQLFy1q3pQZnZsUg/CNT5fiTtIgTe9imPuOfO5qchem7nJJchnamvKQ5vckaaYMCs9Q3 SHTyS9BXi+IMdbAbSH8f4wDbBiPaFZcZs1LzRS1E7frTmxDDyJSUAq0SZPf9exevNXOQ neKH5B+crYFldE4C9KKZrXDwY+wZgDXtrlx+MVyIUQiUcaxo6KovpGbLvVzvnvijGNn7 6HxiQQnqlwTKAWTJNtriLkRXfRCQetyEHoyfMuewIptb6sXp+1vbNQMPej/gx6ozizR0 SBwg== X-Gm-Message-State: APzg51DDKJpQBf5487rle3uWcV2iQ+jo32Vyzo4ArqPbsrovINpncgOt zLhky4QoANSMWHagPEdrxJjvig== X-Received: by 2002:a17:902:82c5:: with SMTP id u5-v6mr2895664plz.83.1535487237583; Tue, 28 Aug 2018 13:13:57 -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.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Aug 2018 13:13:56 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Johannes Berg Subject: [PATCH for-4.9.y 09/14] nl80211: fix null-ptr dereference on invalid mesh configuration Date: Wed, 29 Aug 2018 01:43:20 +0530 Message-Id: <1535487205-26280-10-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: Johannes Berg commit 265698d7e6132a2d41471135534f4f36ad15b09c upstream. If TX rates are specified during mesh join, the channel must also be specified. Check the channel pointer to avoid a null pointer dereference if it isn't. Reported-by: Jouni Malinen Fixes: 8564e38206de ("cfg80211: add checks for beacon rate, extend to mesh") Signed-off-by: Johannes Berg Signed-off-by: Amit Pundir --- net/wireless/nl80211.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.7.4 diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 5b75468b5acd..d8002be808f2 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -9480,6 +9480,9 @@ static int nl80211_join_mesh(struct sk_buff *skb, struct genl_info *info) if (err) return err; + if (!setup.chandef.chan) + return -EINVAL; + err = validate_beacon_tx_rate(rdev, setup.chandef.chan->band, &setup.beacon_rate); if (err) From patchwork Tue Aug 28 20:13:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 145366 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1589383ljw; Tue, 28 Aug 2018 13:14:03 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZCkTAXT5r5x7nqi5MJLFyd1FeQC2Nk94yDGhf+Y7AKguV1nYbdCaq27+jSqHjSoUalRnEn X-Received: by 2002:a63:de10:: with SMTP id f16-v6mr2873280pgg.97.1535487243430; Tue, 28 Aug 2018 13:14:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535487243; cv=none; d=google.com; s=arc-20160816; b=s7Md70Rhjer5HfHpadQ0LbfAdgPGGqQUtDLcQzXj70X7LUABe1kqs2mNlU4hu0G57R 0BhSjuUaBzjOXK5hgnNewdBGml569Cbwr1S4C2Rn2DdK10beTMw9LuVlKjRJLMJGUWws u2pz4pes+gSF1CVZD4ZoVPPY/7Izpz0ifGyhaP+G2QuJoL5iEB4RjfsoqyLv1a80Ih1y 9Fo8vuSUFNlj88abQFXgQULKN6+B1830o+2tle2iRNg/osm8T/Dpulpb4uVp68l3aCRL sDnKcPjs7ian571ihk4Tx/r70XfaV6ft94ezrzt2BfIqb+EqrhR5zIO6zsfcwxr9tq5N J25w== 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=pManMXc5BRtQsqH+JUzfaDh+UG1RtWI46x4cSZ2txCQ=; b=WHZxLhCakupDnONasyEuzyxSMcBA2KhCTTvpFlEytMXLKXbRYUOKDudq9PXtvGtUbP VX7BJjPNVdRyTFKwDWgCJVv/xwZqAnDwVEKyE2t2FXO4coY775gRFXWWzziWR7MLGs1s tz+3UyiEMhmy6dLES5NRPEfVdS4KL038Bzcm7n5kpGavmhDko8xLFifGk/s61p8ystfO s2pkftLIIB/hdSeUHWPS5g++DgQbRfbn8SBj9OEhmgF19n9KDWT33M6Hy3ov6sXp9fa2 JpM+PdZTVzPr39G+dyZRSjLix264MW9aBM6ntHLm/UzcQulilshMwbqxPXHVOzOIN4DX ohxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Fi/NIJOk"; 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.14.03; Tue, 28 Aug 2018 13:14:03 -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="Fi/NIJOk"; 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 S1727179AbeH2AHQ (ORCPT + 13 others); Tue, 28 Aug 2018 20:07:16 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:43619 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726961AbeH2AHQ (ORCPT ); Tue, 28 Aug 2018 20:07:16 -0400 Received: by mail-pg1-f193.google.com with SMTP id v66-v6so1232140pgb.10 for ; Tue, 28 Aug 2018 13:14:02 -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=pManMXc5BRtQsqH+JUzfaDh+UG1RtWI46x4cSZ2txCQ=; b=Fi/NIJOkEE20r7nuFFBNqdvr/1e7zDoVi7CCzaNzpa8i0feXJIiFZOngYxee/NZ717 HxvVH01UF7JDG3nOLLMKP89dlG1PU6RNCpx3NDhXQ0oh9r8HRl/DjpWWydnG1dUuu+MJ M1nzF6Lv/hy2zWKVeOKmyUXc89FpOxM5tBnKw= 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=pManMXc5BRtQsqH+JUzfaDh+UG1RtWI46x4cSZ2txCQ=; b=j2QASP3QskwCqmo9tQG033FyeOeXlCdeCaA/nDDWjg9h8j8I7nfxIjF+imILVvetPH pna2AzCRx5VMatTd8IZv09sktpR08kEImt48+YO6AIKDu/pGwHXtErb98bwScjIAQ/pa QP3UVXPcEOlDfWzL9aZQQUkbMmkqo4DU0TU/MLQSU2NHOMx2NoU14cZZ470TVNrJ5IUg qW4SAzgpf219/0+J5uotn18USctCqaJ9tBmPvjwNLGb98wEoLUMAjE0vIwht+BUOxArR 4sYWcXN64zP0eV4+FbV4EnHBAE3O2Q8mXwi9Gz1NWSOkPjcF9MmyphErEB3XCZYdW5Zq gUtw== X-Gm-Message-State: APzg51A08iDnxnjnLl6XLMpwQN+6jhW1lqPeK/ZpP/QrGYykmC5eRriq fk6gkp5ZZEUyAr9SyxVCe+ytgg== X-Received: by 2002:a62:9e08:: with SMTP id s8-v6mr3004788pfd.23.1535487241709; Tue, 28 Aug 2018 13:14:01 -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.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Aug 2018 13:14:00 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Prateek Sood , Peter Zijlstra , Linus Torvalds , Thomas Gleixner , dave@stgolabs.net, longman@redhat.com, parri.andrea@gmail.com, sramana@codeaurora.org, Ingo Molnar Subject: [PATCH for-4.9.y 10/14] locking/rwsem-xadd: Fix missed wakeup due to reordering of load Date: Wed, 29 Aug 2018 01:43:21 +0530 Message-Id: <1535487205-26280-11-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: Prateek Sood commit 9c29c31830a4eca724e137a9339137204bbb31be upstream. If a spinner is present, there is a chance that the load of rwsem_has_spinner() in rwsem_wake() can be reordered with respect to decrement of rwsem count in __up_write() leading to wakeup being missed: spinning writer up_write caller --------------- ----------------------- [S] osq_unlock() [L] osq spin_lock(wait_lock) sem->count=0xFFFFFFFF00000001 +0xFFFFFFFF00000000 count=sem->count MB sem->count=0xFFFFFFFE00000001 -0xFFFFFFFF00000001 spin_trylock(wait_lock) return rwsem_try_write_lock(count) spin_unlock(wait_lock) schedule() Reordering of atomic_long_sub_return_release() in __up_write() and rwsem_has_spinner() in rwsem_wake() can cause missing of wakeup in up_write() context. In spinning writer, sem->count and local variable count is 0XFFFFFFFE00000001. It would result in rwsem_try_write_lock() failing to acquire rwsem and spinning writer going to sleep in rwsem_down_write_failed(). The smp_rmb() will make sure that the spinner state is consulted after sem->count is updated in up_write context. Signed-off-by: Prateek Sood Signed-off-by: Peter Zijlstra (Intel) Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: dave@stgolabs.net Cc: longman@redhat.com Cc: parri.andrea@gmail.com Cc: sramana@codeaurora.org Link: http://lkml.kernel.org/r/1504794658-15397-1-git-send-email-prsood@codeaurora.org Signed-off-by: Ingo Molnar Signed-off-by: Amit Pundir --- To be applied on 4.4.y as well. Build tested on v4.4.153. kernel/locking/rwsem-xadd.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) -- 2.7.4 diff --git a/kernel/locking/rwsem-xadd.c b/kernel/locking/rwsem-xadd.c index 2337b4bb2366..a4112dfcd0fb 100644 --- a/kernel/locking/rwsem-xadd.c +++ b/kernel/locking/rwsem-xadd.c @@ -574,6 +574,33 @@ struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem) WAKE_Q(wake_q); /* + * __rwsem_down_write_failed_common(sem) + * rwsem_optimistic_spin(sem) + * osq_unlock(sem->osq) + * ... + * atomic_long_add_return(&sem->count) + * + * - VS - + * + * __up_write() + * if (atomic_long_sub_return_release(&sem->count) < 0) + * rwsem_wake(sem) + * osq_is_locked(&sem->osq) + * + * And __up_write() must observe !osq_is_locked() when it observes the + * atomic_long_add_return() in order to not miss a wakeup. + * + * This boils down to: + * + * [S.rel] X = 1 [RmW] r0 = (Y += 0) + * MB RMB + * [RmW] Y += 1 [L] r1 = X + * + * exists (r0=1 /\ r1=0) + */ + smp_rmb(); + + /* * If a spinner is present, it is not necessary to do the wakeup. * Try to do wakeup only if the trylock succeeds to minimize * spinlock contention which may introduce too much delay in the From patchwork Tue Aug 28 20:13:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 145367 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1589407ljw; Tue, 28 Aug 2018 13:14:05 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbwoU9xtybp+Efb9b8RhFRAgqIGS7IvJb7xO/XuUyfxvKhPHsHViehEQ15b0Ln8YFfwicQQ X-Received: by 2002:a63:9712:: with SMTP id n18-v6mr2827382pge.92.1535487245711; Tue, 28 Aug 2018 13:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535487245; cv=none; d=google.com; s=arc-20160816; b=HbKg62Tkw+2LXViWsLV3PMqmoec0pZIWtiDtsj4GM76M0cqaEsikatjYzW92wlk3tT UttJW/dnfL3rGu+LKBNDO7AetlLkSnqcbEsIx+d/4Bft7Q1KmCqHZ56axFztzHKV95lX ooQ13LMM8pSl8lFRAPo1mmZgA0y5BmsuyhbY+/IPh6m5PLxaJ0LXtW1PKXohuj73tmcm FzWH2/QVsDTHR51Pz6WOI/UxqJFM8/+rRLr9/GKgx2+qm4G2x9ozxLo0VBHq462Sg3GS VH5gyYvNUDXa9cVA3vs766Yfx2bCCOFudRQWy0qbLmZ32Wzzj/DfG7LU/fBgiMFPk8+D pyrg== 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=QG2jYi4xbZtB60lhzSK5hjQqa5E/smq1fH4liWdBk/s=; b=raksobLpd81Pmla0/s5HvCK1taRTLqPcuA1sFoR9hQZLhIIGD3n7X67h7VMpYveZ+4 a1kHla+PtcmahDN7Lha6EHZ02SzE9/3kJFb+j+sOKdQFNl/WlBxOTZmjmMvvtTcBX92l Gd7+k6m7YBVxskVg7tjBNWPdQs2FPUFhOW6t+qjQAEaogAKTZk5kjuItiXtL4SR14dPm +874Q8Y9GumpvRHG/uD+DCsuajVJs6y9oYlfsw3OqM/zx3sgyOZ0TshfHcpLuMVNt5Qa dewsiAt6/Vb7EBRi/6BvxIWrwiyZkxcImPHqkCe/ATyZhRjNeZ2ypGfPKiRBvjS+BXQx hGDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gVoUbeIz; 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.14.05; Tue, 28 Aug 2018 13:14:05 -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=gVoUbeIz; 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 S1727181AbeH2AHT (ORCPT + 13 others); Tue, 28 Aug 2018 20:07:19 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:40970 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726961AbeH2AHT (ORCPT ); Tue, 28 Aug 2018 20:07:19 -0400 Received: by mail-pg1-f195.google.com with SMTP id s15-v6so1237356pgv.8 for ; Tue, 28 Aug 2018 13:14:04 -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=QG2jYi4xbZtB60lhzSK5hjQqa5E/smq1fH4liWdBk/s=; b=gVoUbeIzq4q2IlrFgVlJa3mgF4iiQ101kkX+fKT4apaHt/w6XoiLbzEYP8+BMPh7ZL fzqE5SnuGRTyS+YWVFmDGjFnn6P92Z69ZMWvDGaHJEHWnI1996d/oC01PoXh0m2mIbRG ul/fkfbZm0pl6lDMlhzdfk7zoY8c9pVNer8uU= 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=QG2jYi4xbZtB60lhzSK5hjQqa5E/smq1fH4liWdBk/s=; b=LTRWq1CIP9PdidjVoo4tprQUwbo6FKHH4j6kuVyGIglrMbmGCN8TFHbLxJjLpH2JAm GT1cK1xdDcjIt9FI3SuSY/srpIpTJq3x8iM3qGbkpy+z5rORVdamuZp1IbsGw73VB7wF 9PE0P3PvqWLf4TdNadJCgv1L/qA9RkKRWX6m/BU7PC/eHkoAKxQI4riQuCa3Z8bS66KC Nb1mDKJfxb7lkjrcIJcJ0Wvd3WfEYxlnfv8O/y9vwl9l/jSYJ1DCwSEaBKuyqxusLFlv SO+/RlEkOmVXe53D2hZq5DSgco2VUz4HS4kqQVTpzgHpiA8gdy3ezfjCfp0AM0MF4IpJ uZ0w== X-Gm-Message-State: APzg51Br0ZGg2lfx4l8w6HsSR6VBr/0tjWqMmyCN7J8QkCRJi+pWcORP 4OulpV43BGRdfBtgz7MOow/mlw== X-Received: by 2002:a62:5ec3:: with SMTP id s186-v6mr3000822pfb.146.1535487244378; Tue, 28 Aug 2018 13:14:04 -0700 (PDT) Received: from localhost.localdomain ([49.207.48.21]) by smtp.gmail.com with ESMTPSA id t86-v6sm3098181pfe.109.2018.08.28.13.14.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Aug 2018 13:14:03 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Michal Hocko , Paul Moore Subject: [PATCH for-4.9.y 11/14] selinux: use GFP_NOWAIT in the AVC kmem_caches Date: Wed, 29 Aug 2018 01:43:22 +0530 Message-Id: <1535487205-26280-12-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: Michal Hocko commit 476accbe2f6ef69caeebe99f52a286e12ac35aee upstream. There is a strange __GFP_NOMEMALLOC usage pattern in SELinux, specifically GFP_ATOMIC | __GFP_NOMEMALLOC which doesn't make much sense. GFP_ATOMIC on its own allows to access memory reserves while __GFP_NOMEMALLOC dictates we cannot use memory reserves. Replace this with the much more sane GFP_NOWAIT in the AVC code as we can tolerate memory allocation failures in that code. Signed-off-by: Michal Hocko Acked-by: Mel Gorman Signed-off-by: Paul Moore Signed-off-by: Amit Pundir --- To be applied on 4.4.y as well. Build tested on v4.4.153. security/selinux/avc.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/security/selinux/avc.c b/security/selinux/avc.c index e60c79de13e1..52f3c550abcc 100644 --- a/security/selinux/avc.c +++ b/security/selinux/avc.c @@ -348,27 +348,26 @@ static struct avc_xperms_decision_node struct avc_xperms_decision_node *xpd_node; struct extended_perms_decision *xpd; - xpd_node = kmem_cache_zalloc(avc_xperms_decision_cachep, - GFP_ATOMIC | __GFP_NOMEMALLOC); + xpd_node = kmem_cache_zalloc(avc_xperms_decision_cachep, GFP_NOWAIT); if (!xpd_node) return NULL; xpd = &xpd_node->xpd; if (which & XPERMS_ALLOWED) { xpd->allowed = kmem_cache_zalloc(avc_xperms_data_cachep, - GFP_ATOMIC | __GFP_NOMEMALLOC); + GFP_NOWAIT); if (!xpd->allowed) goto error; } if (which & XPERMS_AUDITALLOW) { xpd->auditallow = kmem_cache_zalloc(avc_xperms_data_cachep, - GFP_ATOMIC | __GFP_NOMEMALLOC); + GFP_NOWAIT); if (!xpd->auditallow) goto error; } if (which & XPERMS_DONTAUDIT) { xpd->dontaudit = kmem_cache_zalloc(avc_xperms_data_cachep, - GFP_ATOMIC | __GFP_NOMEMALLOC); + GFP_NOWAIT); if (!xpd->dontaudit) goto error; } @@ -396,8 +395,7 @@ static struct avc_xperms_node *avc_xperms_alloc(void) { struct avc_xperms_node *xp_node; - xp_node = kmem_cache_zalloc(avc_xperms_cachep, - GFP_ATOMIC|__GFP_NOMEMALLOC); + xp_node = kmem_cache_zalloc(avc_xperms_cachep, GFP_NOWAIT); if (!xp_node) return xp_node; INIT_LIST_HEAD(&xp_node->xpd_head); @@ -550,7 +548,7 @@ static struct avc_node *avc_alloc_node(void) { struct avc_node *node; - node = kmem_cache_zalloc(avc_node_cachep, GFP_ATOMIC|__GFP_NOMEMALLOC); + node = kmem_cache_zalloc(avc_node_cachep, GFP_NOWAIT); if (!node) goto out; From patchwork Tue Aug 28 20:13:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 145368 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1589455ljw; Tue, 28 Aug 2018 13:14:09 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaORpMoyroaO0VzKckqAcQuxVOv1ZUL6uLeuCw8tTz0vAGWVjJe1ERUo+HFfAmZ0C5vjQcj X-Received: by 2002:a63:f111:: with SMTP id f17-v6mr2812413pgi.87.1535487249640; Tue, 28 Aug 2018 13:14:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535487249; cv=none; d=google.com; s=arc-20160816; b=H7QKDoE1dP/Rx9I+NjwROdvMXKDbcMzQnAm//QmhgdO2RVe+J5ru7+K9f2na4su9Kz ht66CVlSh4PcrSagj+2PF+MQIs/o0msA3+4hmFvqALVCf9R7sdMR7/a+aNEbmf9FYmu8 lO53FUZkLShRgWqXcMOOogWTjKRyd3J1bgA8+6f4vxZuTlkwh2oMBso269A7bPGaLNRm /lp4VzbOPK9jhNTfctgvoQ67JFL95nWoLkzx6jHbQV3dZQmDJsmd7q4geijX40SjrwKU bJ4h4W/pq8ixzQwpNejM5iUGnDMuW2XVrdWNtDEKCKVRJ1uBoHCQ5k8JV95nar8b9vjx GEDA== 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=FwrE8QRLzDSVDpybvsbsFCrkig0rVq395QXSR7cbD5s=; b=ZKDe13gRWu2dFAg2RsssBCnd0x+Dg0aXw/v5de9Ty6mwam5cHV/Lfx48XhHDreYUw+ rCvhp0di7NZwYF65pOn3tWu6zLL0w8v+loR5qgxJlt+qtMTsKL12Z+A7sOxdlkavB4wD sQwf/+YY7PP9abRiWhWFzB9yZrdoV+1OTi3TFPMqDq5TMUKrZUDYwtq9wLCth/QCxPEC XX52XnD9k4lqd0zUSz0jeLTgEdP/ktdtKCZjqgskV+keM4t4ZDWpTjKSpEhRfZA78eJA 3oatz7Oi0zMK1EGwrWosJRVsOLpkygwkvLH6bOWQDJHkhHI7aFzNqCpE5USIMv0LHsOe NKXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="AW/Use2+"; 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.14.09; Tue, 28 Aug 2018 13:14:09 -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="AW/Use2+"; 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 S1727193AbeH2AHX (ORCPT + 13 others); Tue, 28 Aug 2018 20:07:23 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44779 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726961AbeH2AHW (ORCPT ); Tue, 28 Aug 2018 20:07:22 -0400 Received: by mail-pg1-f195.google.com with SMTP id r1-v6so1229741pgp.11 for ; Tue, 28 Aug 2018 13:14:08 -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=FwrE8QRLzDSVDpybvsbsFCrkig0rVq395QXSR7cbD5s=; b=AW/Use2++byq9Zs1yN1cgxL7cGmtdB3V4GWhkO4Y7QuSFVjNvc79/QCBj6/Cv8Buqt 2qQWz7aA/Ysu797K33TFeOlTOTARTzSDvnzvW5dfEN/vQFZEMjGdZILQCOemUICO7u6Q j5CzNlLWdEUZqE58HqJLpG9Etgp9nGBhx0wws= 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=FwrE8QRLzDSVDpybvsbsFCrkig0rVq395QXSR7cbD5s=; b=E7r1nso0rM0lNZXs7cc0ENHk9QN2xaTXJDaqVDrtMRCrFJF9D14FyWLK/ugwsUn4xI oetD2BtgkLFczbj5D7SFUQ72BBOm58K+cPQvz8vw5qgWUjR/orTCRS1T51UeX0JcX8lz /dWRNj5mIJ9YOGpS5j1xUmQooilDW64VwXAgJkgUtBVpofISqMnpObi0JhDI4auzxjvD ZoFrmhQhRdEhyNNw0rWKxxROtryHuMYG1ONBZxHrKO9PuRz/8W7liZxIjbbcLJ3rCH1D xnOb/coyS07W0XDwUg28zwB8H4AZoaXtmEY0wCFbaOINimN502h/gYbHuS2sq3ojC7dv ZdVQ== X-Gm-Message-State: APzg51DaOJQJyNg1VHyHsr67xl7Cr0tANWuLgeYlvaPqhfND3yUJuTru dKSecCQZQImQ6QfMZ067HVyPmQ== X-Received: by 2002:a65:650f:: with SMTP id x15-v6mr2939261pgv.127.1535487247818; Tue, 28 Aug 2018 13:14:07 -0700 (PDT) Received: from localhost.localdomain ([49.207.48.21]) by smtp.gmail.com with ESMTPSA id t86-v6sm3098181pfe.109.2018.08.28.13.14.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Aug 2018 13:14:06 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Prateek Sood , Peter Zijlstra , Linus Torvalds , Thomas Gleixner , sramana@codeaurora.org, Ingo Molnar Subject: [PATCH for-4.9.y 12/14] locking/osq_lock: Fix osq_lock queue corruption Date: Wed, 29 Aug 2018 01:43:23 +0530 Message-Id: <1535487205-26280-13-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: Prateek Sood commit 50972fe78f24f1cd0b9d7bbf1f87d2be9e4f412e upstream. Fix ordering of link creation between node->prev and prev->next in osq_lock(). A case in which the status of optimistic spin queue is CPU6->CPU2 in which CPU6 has acquired the lock. tail v ,-. <- ,-. |6| |2| `-' -> `-' At this point if CPU0 comes in to acquire osq_lock, it will update the tail count. CPU2 CPU0 ---------------------------------- tail v ,-. <- ,-. ,-. |6| |2| |0| `-' -> `-' `-' After tail count update if CPU2 starts to unqueue itself from optimistic spin queue, it will find an updated tail count with CPU0 and update CPU2 node->next to NULL in osq_wait_next(). unqueue-A tail v ,-. <- ,-. ,-. |6| |2| |0| `-' `-' `-' unqueue-B ->tail != curr && !node->next If reordering of following stores happen then prev->next where prev being CPU2 would be updated to point to CPU0 node: tail v ,-. <- ,-. ,-. |6| |2| |0| `-' `-' -> `-' osq_wait_next() node->next <- 0 xchg(node->next, NULL) tail v ,-. <- ,-. ,-. |6| |2| |0| `-' `-' `-' unqueue-C At this point if next instruction WRITE_ONCE(next->prev, prev); in CPU2 path is committed before the update of CPU0 node->prev = prev then CPU0 node->prev will point to CPU6 node. tail v----------. v ,-. <- ,-. ,-. |6| |2| |0| `-' `-' `-' `----------^ At this point if CPU0 path's node->prev = prev is committed resulting in change of CPU0 prev back to CPU2 node. CPU2 node->next is NULL currently, tail v ,-. <- ,-. <- ,-. |6| |2| |0| `-' `-' `-' `----------^ so if CPU0 gets into unqueue path of osq_lock it will keep spinning in infinite loop as condition prev->next == node will never be true. Signed-off-by: Prateek Sood [ Added pictures, rewrote comments. ] Signed-off-by: Peter Zijlstra (Intel) Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: sramana@codeaurora.org Link: http://lkml.kernel.org/r/1500040076-27626-1-git-send-email-prsood@codeaurora.org Signed-off-by: Ingo Molnar Signed-off-by: Amit Pundir --- To be applied on 4.4.y as well. Build tested on v4.4.153. kernel/locking/osq_lock.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) -- 2.7.4 diff --git a/kernel/locking/osq_lock.c b/kernel/locking/osq_lock.c index 05a37857ab55..8d7047ecef4e 100644 --- a/kernel/locking/osq_lock.c +++ b/kernel/locking/osq_lock.c @@ -104,6 +104,19 @@ bool osq_lock(struct optimistic_spin_queue *lock) prev = decode_cpu(old); node->prev = prev; + + /* + * osq_lock() unqueue + * + * node->prev = prev osq_wait_next() + * WMB MB + * prev->next = node next->prev = prev // unqueue-C + * + * Here 'node->prev' and 'next->prev' are the same variable and we need + * to ensure these stores happen in-order to avoid corrupting the list. + */ + smp_wmb(); + WRITE_ONCE(prev->next, node); /* From patchwork Tue Aug 28 20:13:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 145369 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1589487ljw; Tue, 28 Aug 2018 13:14:13 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYxzTGcw/Jv5Ryl/7FqiJOipFvI/xW8g1jHtDDn8Sg5ZjMfg6jBR/3Wa0PGYRFH9USGeLR2 X-Received: by 2002:a63:cb0f:: with SMTP id p15-v6mr2933439pgg.197.1535487252888; Tue, 28 Aug 2018 13:14:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535487252; cv=none; d=google.com; s=arc-20160816; b=wGoeWfzHZdiiY34XQGKmegn5AX9DbisF3LbU6/dyxHQuMGtA9eALRIi6lATPM95MNV eg1clAT/fa5EabzZrZ+mi9Hhblp5QOIvjW49gBEgNMoEnp9IBBAf/iu5gKwZzic+gL3y EHvpsdGtbqqVP1VuiQVVnW7V7Qnmcl3PCawETn8kSFj63hHUzDbwxxVYuov0lnfJnI2Z f2n5SJhlCm/6YdPtQHkBOlHYVRBKliMLTrhMhjX/7KUVVxubyrqT0dPcKEalnK5LYwP/ SfR+uxorIOPEgd8KJxkGxvGFbFsBdnbFHa9sgIWVL7ZyG4L6wylmky/cnN8z1hZdBLXT AV0w== 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=eQ/m9DUVdjAicHlgJxoQOKTZjadCXQDS84km0LuGv28=; b=fkOg7wYLq/Ihv3L6WDzOQNq7a6NUNZZVJZTSWysIL+CSF0QZDGpsmH8OgQOBDyg0Pr lCBM/jyCn2OLkohCIpubvOSWu4a/5ClF7qrRkB/sTFKRFMejyUdbJHlarc7viIMFYnZc txfqr1zH0soLYwg0MWrZ9aApgBSPLrynSSTyGVPWkD579e43ikYjG1xo6S92aUgTvEX7 eSd2j8NY3zLgvJknI/K5tj/k0Fu8gBUajyyBULh3FPqs1lCf3U8iKGIzQAU7F++oBXnC o/zoj5dC6fMyD6D5PuvOxW15/KAKObYfNZO2mtaeCNDUzIyRtBdbDvqTvQ7Po0n7zlXd c/5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Znt5YZ3m; 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.14.12; Tue, 28 Aug 2018 13:14:12 -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=Znt5YZ3m; 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 S1727199AbeH2AH0 (ORCPT + 13 others); Tue, 28 Aug 2018 20:07:26 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37266 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726961AbeH2AH0 (ORCPT ); Tue, 28 Aug 2018 20:07:26 -0400 Received: by mail-pg1-f193.google.com with SMTP id 2-v6so717748pgo.4 for ; Tue, 28 Aug 2018 13:14:11 -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=eQ/m9DUVdjAicHlgJxoQOKTZjadCXQDS84km0LuGv28=; b=Znt5YZ3mFIC5ZwbY5gDF4rrln4fKwT14+YwK9Ob25fOXnb8SA+CmhTD/+WQE0ST+nA cMowuqAIV93WDIG0ZcgULi6ilknFRwlJv15q54wFZt5Zzu8/Ur5jUu/fIriD3ag+blD8 z/9uvgOLxr7c0ZOoiSqVGxcUBu5rmsKKxES7I= 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=eQ/m9DUVdjAicHlgJxoQOKTZjadCXQDS84km0LuGv28=; b=UZlBqLP6p4qg8svZMFO63rjyAE8LqTatvjYTFWIyATEg8mAZxjaRvYkDAKlXH8ER7q ZamM0r41rZIZ8LSJrU21g1jLGhuk/78pBZ4od9eDpmYFWAE77TRksvl/eELLPLyjDsWN e5nmq7rceXEmLmbKevq4iC5HCIyiKdMRsmOTKK+bCekFEMsqG77Kv/j9FOKJza9CHsqN DzFqb92c0RNZA7r9bckL5QWVJo9ookj6Je2gtgj6/pSXoUQso2t5ho3hKUaseYX8KVLj fx4Cva2hTJ6ErAeIBkSIW14qCsx4PheWTuHsnnZRgbR5t+W21j8PzbTwaDCyB56bhocd xOIQ== X-Gm-Message-State: APzg51C83Uei42G2yVrCAQR5k6XzkE/BvnWwDiiR65YY5MEV9DAhARXq 90t2I9x5z3KH0UefK8JF7s42b8gAZO5iDw== X-Received: by 2002:a62:411a:: with SMTP id o26-v6mr2995128pfa.111.1535487251160; Tue, 28 Aug 2018 13:14:11 -0700 (PDT) Received: from localhost.localdomain ([49.207.48.21]) by smtp.gmail.com with ESMTPSA id t86-v6sm3098181pfe.109.2018.08.28.13.14.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Aug 2018 13:14:10 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Mel Gorman , Minchan Kim , Rik van Riel , Andrew Morton , Linus Torvalds Subject: [PATCH for-4.9.y 13/14] mm, vmscan: clear PGDAT_WRITEBACK when zone is balanced Date: Wed, 29 Aug 2018 01:43:24 +0530 Message-Id: <1535487205-26280-14-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: Mel Gorman commit c2f83143f1c67d186520b72b6cefbf0aa07a34ee upstream. Hillf Danton pointed out that since commit 1d82de618dd ("mm, vmscan: make kswapd reclaim in terms of nodes") that PGDAT_WRITEBACK is no longer cleared. It was not noticed as triggering it requires pages under writeback to cycle twice through the LRU and before kswapd gets stalled. Historically, such issues tended to occur on small machines writing heavily to slow storage such as a USB stick. Once kswapd stalls, direct reclaim stalls may be higher but due to the fact that memory pressure is required, it would not be very noticable. Michal Hocko suggested removing the flag entirely but the conservative fix is to restore the intended PGDAT_WRITEBACK behaviour and clear the flag when a suitable zone is balanced. Fixes: 1d82de618ddd ("mm, vmscan: make kswapd reclaim in terms of nodes") Link: http://lkml.kernel.org/r/20170203203222.gq7hk66yc36lpgtb@suse.de Signed-off-by: Mel Gorman Acked-by: Johannes Weiner Acked-by: Michal Hocko Acked-by: Hillf Danton Cc: Minchan Kim Cc: Rik van Riel Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Amit Pundir --- mm/vmscan.c | 1 + 1 file changed, 1 insertion(+) -- 2.7.4 diff --git a/mm/vmscan.c b/mm/vmscan.c index f03ca5ab86b1..cfffef1f26a8 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3123,6 +3123,7 @@ static bool zone_balanced(struct zone *zone, int order, int classzone_idx) */ clear_bit(PGDAT_CONGESTED, &zone->zone_pgdat->flags); clear_bit(PGDAT_DIRTY, &zone->zone_pgdat->flags); + clear_bit(PGDAT_WRITEBACK, &zone->zone_pgdat->flags); return true; } From patchwork Tue Aug 28 20:13:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 145370 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1589532ljw; Tue, 28 Aug 2018 13:14:16 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb58seCM726NcJECmlf1q+8MW31kbLd+8wI8Wk0xzo7+hk7IrrwEt/AYNZZrxaNqDYcv5mS X-Received: by 2002:a17:902:e190:: with SMTP id cd16-v6mr2880682plb.305.1535487256090; Tue, 28 Aug 2018 13:14:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535487256; cv=none; d=google.com; s=arc-20160816; b=J9ZeRt5Lhs/kRzK4VRGjWOUko0W7nyi2c95FZdPABjQNVZ/YszfuSAgLpDNUV/nUt9 yIGQvgNt8qUXovxWG1tUxHhtgU0WQ5ZPplsbrH1B37RC9sbXrxd7bFbgV354PTB+zJ4E dV0KG/BIgkkJ35hrXGH7xRLsd5tjlW3owhS6tN4UXIhw6y/3HKDdtLjWWslwJ8eq3phs YHMjCImTgizfBq1/g7M+I08oz7zzQEe5YQVnQK4RWxoIy9m5C0ae4YiKAKxlAMKqP6n3 sm/knE+CYIfcOIREFDV3fJq6oQ/MQn3rdo1QZ4d5eFAhHHaMrA6w5n+OnhiyjhCLGHsK zc2Q== 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=C0nQimwuIw9aUPcGBBVl1Omj2YnwzA/ET0MZeeWEF3U=; b=jACX1mjOeHrPiRNxT3GseplV//kKQoK+TOwA35BhaPV6k6Eu0h9CZU8NQGYSslYCmX pW6EJinI4ahoiElsj7TDX/1CFOaCmSNENgvBal169UrLnDTxX9a62rBKN4cGqp3l/LLN ha5JdkcFZf4YRxV+8ZpzySh9eWVmdZvM81JVQHCC6+jUavyJ2Bc5KUjUql+2KIK82yFZ e2vj3L+YhM95ctYTI0XO0ZRm3GwcDaN200qxK6Fx5ngudIi9NV+ed7DWafMd0XR4JC+d wShiKEm3QsQYaDkmpfDuL6Tv/HtCv9cvs44JQy1IICP/bAXojUoSG+0MrHOTj86VFoQw DPEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PliUOURu; 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.14.15; Tue, 28 Aug 2018 13:14:16 -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=PliUOURu; 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 S1727201AbeH2AH3 (ORCPT + 13 others); Tue, 28 Aug 2018 20:07:29 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:36553 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726961AbeH2AH3 (ORCPT ); Tue, 28 Aug 2018 20:07:29 -0400 Received: by mail-pl1-f195.google.com with SMTP id e11-v6so1211164plb.3 for ; Tue, 28 Aug 2018 13:14:14 -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=C0nQimwuIw9aUPcGBBVl1Omj2YnwzA/ET0MZeeWEF3U=; b=PliUOURumiIr4SIemwKq/8B7HUV9vjws+Q10q0K9xy14sUx8OMQfuiiTxQ15jf6YZO YVEQU8qRHK7YwzZpOqNxpXaanjZHb5kAS5qkKhKGQTGj6TAcEzhikla/b5T+fF8bZ91q xBk9z+I9mvQeOq14I0jALgZbA2hBTn2N4uX/4= 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=C0nQimwuIw9aUPcGBBVl1Omj2YnwzA/ET0MZeeWEF3U=; b=nQ0SvI8fGY4rEJiSWrtVt17wVUVxfM2ElPV2U9PLJdwA4ugvA3U8H6fFBq6ESM2RLV bL/Oip/SQ8XIujqYUOOr6MFLBMQqv8ZE1SrtKdx88SEzrrOf8LJ2sYzdzk3WMqh8s25h 4Pki20pXt8KzH1eyYOF5GpL1IJirG0GlA9UF1NMHXg/nvESCBgHZip7OaspH2ez+pmun NOuZhWi7pNXWga1/aPnOS66c+0XUppZCc7CXTA7ZTXqfCUYuLQgUoM8KAQHZFUEKHL1K s0z18L6U42PJewjuyMBJ6nk+SEfgfN1f/2gTVeZ4az5YvScxrLhaHs9PvdVGchLoea8D qNNg== X-Gm-Message-State: APzg51D+RDFoOkcxYiq67UlzOv3OQkPIZE5bLE06sOFGwrqobSfaFosW jbIJrTZHF7J2m9sbIHKjYsckyHG13OCF9Q== X-Received: by 2002:a17:902:722:: with SMTP id 31-v6mr2880769pli.207.1535487254481; Tue, 28 Aug 2018 13:14:14 -0700 (PDT) Received: from localhost.localdomain ([49.207.48.21]) by smtp.gmail.com with ESMTPSA id t86-v6sm3098181pfe.109.2018.08.28.13.14.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Aug 2018 13:14:13 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Johannes Weiner , Jia He , Andrew Morton , Linus Torvalds Subject: [PATCH for-4.9.y 14/14] mm: remove seemingly spurious reclaimability check from laptop_mode gating Date: Wed, 29 Aug 2018 01:43:25 +0530 Message-Id: <1535487205-26280-15-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: Johannes Weiner commit 047d72c30eedcb953222810f1e7dcaae663aa452 upstream. Commit 1d82de618ddd ("mm, vmscan: make kswapd reclaim in terms of nodes") allowed laptop_mode=1 to start writing not just when the priority drops to DEF_PRIORITY - 2 but also when the node is unreclaimable. That appears to be a spurious change in this patch as I doubt the series was tested with laptop_mode, and neither is that particular change mentioned in the changelog. Remove it, it's still recent. Link: http://lkml.kernel.org/r/20170228214007.5621-4-hannes@cmpxchg.org Signed-off-by: Johannes Weiner Acked-by: Hillf Danton Acked-by: Mel Gorman Acked-by: Michal Hocko Cc: Jia He Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Amit Pundir --- mm/vmscan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/mm/vmscan.c b/mm/vmscan.c index cfffef1f26a8..4e5846b8b5eb 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3301,7 +3301,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx) * If we're getting trouble reclaiming, start doing writepage * even in laptop mode. */ - if (sc.priority < DEF_PRIORITY - 2 || !pgdat_reclaimable(pgdat)) + if (sc.priority < DEF_PRIORITY - 2) sc.may_writepage = 1; /* Call soft limit reclaim before calling shrink_node. */