Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1071564ybl; Wed, 14 Aug 2019 10:14:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyq9tAkjPjuFNtevNPIG2rDRiGKehq9oijSdsgqKaYokvrXfX8siuSoRuJe8oW0yvsEIEHo X-Received: by 2002:a65:4546:: with SMTP id x6mr214331pgr.266.1565802848927; Wed, 14 Aug 2019 10:14:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802848; cv=none; d=google.com; s=arc-20160816; b=U+dN9zKJmGiU/5ZlHPEgcMB6dF+X+Ev0814Jvikca80yl/ds9NEHn92/2kEq8HXIJd BXSqQh9+jAq38/i00tEGgKuRBp8J94PYtgORx2pfOZftzKzwbCSCF3KMvbB5IIDsr4ZA GfITke8WDc7oYmmtnvq3pS7zYfDGJWT2Ni7+CghHAvmCRlOpnQVd15a2vBOMhFNhkCtv pQdzEPHRm3rFYUnLyVDIN+eOxHtemSXr+1twiCdt5pZX9Z4WrkuFQFx688I/yZkEs50c kov+GWX3QRlw0IWgtIqF8YATjlnBQ2C3I0WcEeuSI7/fkCyzxMBvvBfD7kHe6XWpqm00 My6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=guTyeZ8zJFnzMEUcOBSdnqmjYmLucUvhzVe96gp94p4=; b=I6umXY7DnL4eZss3cE402/dR39k8Jpn6qYA1tv1/xE6KRjuhlH/XwfCyLouAEoC3rF 2Xxl+CIh45yEWsixWjBGhvlKb2s4st3yh72XI206/5xkYDth+nq1NGmx5ZUYvZcIkn3Z 4xP7N9oMDpXLzzvgv9C14urCGaY2v1iuJ+vlUtvVr+n/dyCR+dQQ6z3vHt17D1sFLg3/ zgMwgJnVJ03E7XBq5VeM4+GYOsZd7rcgbM6F9a/0nOyjgsVL91LO403vmCr3+OApRusN iyZvtirzfUKpxxWl9v3WGs4azH3k9E8YEGooQ1f6toqLU0qH48LheYtmgYQGOUsOm9NH DTjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mAb0QH0Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1si263307pls.69.2019.08.14.10.13.53; Wed, 14 Aug 2019 10:14:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mAb0QH0Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730669AbfHNRMI (ORCPT + 99 others); Wed, 14 Aug 2019 13:12:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:35722 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729316AbfHNRMG (ORCPT ); Wed, 14 Aug 2019 13:12:06 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 866962063F; Wed, 14 Aug 2019 17:12:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802726; bh=gpA5jfY7E5xa0KgP8ng14YmiMbhoXW6uBtPbe/8/lb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mAb0QH0QgSpeTcXbgTfFuHxRti0sEB5v74xLZ5bifT9/NSikAQ8J9XmjAFoasVobv xddAeD1EAg8+PHujBef2VXFGcCmlTP4y1Z03eDx2asl5YQr3b0/igmEIsJSF2IDAm4 SiWwVW4WzBPsN4tLY1myPYuNpeComuued/RgWaPo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon , "Peter Zijlstra (Intel)" , Linus Torvalds , Peter Hurley , Thomas Gleixner , Ingo Molnar , Sasha Levin Subject: [PATCH 4.19 67/91] tty/ldsem, locking/rwsem: Add missing ACQUIRE to read_failed sleep loop Date: Wed, 14 Aug 2019 19:01:30 +0200 Message-Id: <20190814165752.450174976@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165748.991235624@linuxfoundation.org> References: <20190814165748.991235624@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 952041a8639a7a3a73a2b6573cb8aa8518bc39f8 ] While reviewing rwsem down_slowpath, Will noticed ldsem had a copy of a bug we just found for rwsem. X = 0; CPU0 CPU1 rwsem_down_read() for (;;) { set_current_state(TASK_UNINTERRUPTIBLE); X = 1; rwsem_up_write(); rwsem_mark_wake() atomic_long_add(adjustment, &sem->count); smp_store_release(&waiter->task, NULL); if (!waiter.task) break; ... } r = X; Allows 'r == 0'. Reported-by: Will Deacon Signed-off-by: Peter Zijlstra (Intel) Acked-by: Will Deacon Cc: Linus Torvalds Cc: Peter Hurley Cc: Peter Zijlstra Cc: Thomas Gleixner Fixes: 4898e640caf0 ("tty: Add timed, writer-prioritized rw semaphore") Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- drivers/tty/tty_ldsem.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/tty/tty_ldsem.c b/drivers/tty/tty_ldsem.c index b989ca26fc788..2f0372976459e 100644 --- a/drivers/tty/tty_ldsem.c +++ b/drivers/tty/tty_ldsem.c @@ -116,8 +116,7 @@ static void __ldsem_wake_readers(struct ld_semaphore *sem) list_for_each_entry_safe(waiter, next, &sem->read_wait, list) { tsk = waiter->task; - smp_mb(); - waiter->task = NULL; + smp_store_release(&waiter->task, NULL); wake_up_process(tsk); put_task_struct(tsk); } @@ -217,7 +216,7 @@ down_read_failed(struct ld_semaphore *sem, long count, long timeout) for (;;) { set_current_state(TASK_UNINTERRUPTIBLE); - if (!waiter.task) + if (!smp_load_acquire(&waiter.task)) break; if (!timeout) break; -- 2.20.1