Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp1722460pxb; Sun, 10 Jan 2021 08:19:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfY2DR1CffKn8ABddla7io5z+L0qU+mWlP2se+iPenfwFCZb3Ppx1Jc2P6KSFEy98HYUBJ X-Received: by 2002:a17:907:20a4:: with SMTP id pw4mr8169815ejb.499.1610295593189; Sun, 10 Jan 2021 08:19:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610295593; cv=none; d=google.com; s=arc-20160816; b=mZFSuQ0ZFSKzrjtrtjJiIejUx5eG9+8T/4J1VsXNwsmuMhASBOWbRNewoutacuahEl 2owqq6AdcrWyECgo31nT5WQWjNj8XWiwmg+0u4RLeLmvdYGtUAuMsKJkUS4bS28ObixY TlWlBP7yx8CiWKbg0U/tueZa8nE3LZ1cnJgBttl1lSIS+9fJcFvXftXwhM0tSTKA4yuX BzQMDYGRj4gZbdmhGWq+vQF4p7dVl+n+TzZs2VYeRfgLXBaxYdcLaRBtKWaBNMIVTTzl SCcFKIbkd8TILlmMhuOJY/H4GSGEV05PzPmlniklbXJeSLb2Mtc+sJYGwOO+MClvLP5d Zfvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=O6wD1nNt0PNVbfvKXZ84PNRKQg+59KWjjSHlKIR8nqc=; b=bCoz9ElwxTqpwJ50jvo2codhzWbqhD1UKdZSdbJrKFM98VvRuslk5LJbcBiCcWOki3 3LVGX1mXIy8LiezUCN4jazfTNe7hYxNBTjxh2sRBwoNaOgMB0FZfbl6tn4VqOuGMhBGG kHFgIxZWssgC3KZPW67i70YIPwk1oEMvs6LMvZ8Q+tdDjLZgIFz4LWPPfjKK85rXB+IJ c1e6MLiyxiLHEGtXB8x0sb/h5DGcHaOjFyWZ+dRIXmNOabCHeAhe4jiLVBuZbkoGbasi Ue1aaWB42ZCYHIvvwHXT/SagWsaw10SjKoku5EZRagkSNv3GxDj7GjAmhH4c53b0Geek bgXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XCdtIZkp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pw18si5630787ejb.163.2021.01.10.08.19.29; Sun, 10 Jan 2021 08:19:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XCdtIZkp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726666AbhAJQSw (ORCPT + 99 others); Sun, 10 Jan 2021 11:18:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726080AbhAJQSw (ORCPT ); Sun, 10 Jan 2021 11:18:52 -0500 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79F01C061786; Sun, 10 Jan 2021 08:18:11 -0800 (PST) Received: by mail-ej1-x630.google.com with SMTP id g20so21369016ejb.1; Sun, 10 Jan 2021 08:18:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=O6wD1nNt0PNVbfvKXZ84PNRKQg+59KWjjSHlKIR8nqc=; b=XCdtIZkpWsVx3yECy1NV9GsqgwYPM6RD4jgmwLA3ig1Kkz2ycf/6DMJ4IA8g7Bab+E ehmKpCyZVk+BkU9GvKyccOoiHmpFmOeU5N53h328hGGmdvW9qJp7EDdbh87FfLKcgADT 8yCeDn089v5rDEktNu8nh/GkzXe1oLUlSd86s5WRt/yGlWPgbDcGKZHVQSyoYB5KZ+p/ f3fjQOp73Fz7u3ohi7Ql3IF5RMfdtYJbEJJyOu+hhbMIjhyHEUEDZopuRkKDUOnFYoru EHZvLWdZgbugdaYIWLTpRQ8613td36TY/65lj/cdI3A4NE7siGDQqo2QvaOxTx818Ohr naZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=O6wD1nNt0PNVbfvKXZ84PNRKQg+59KWjjSHlKIR8nqc=; b=IMLtu1Cpd5H/oqOvI1uRsWHmzQhoVA/y78ShwBZxHANxIASbnMNd71sJjUUO80I4Qy m0aE9Trn8ar4OybDgfIqzj6Y6mIbwpxWVQmsJ0rLU/aCgWZ0pRHZO+pCrJmxWNMPaCYs chW3L4J4h3puuLDdqz+F4fTP7HtFyCZKumrJmNBP9klYKxEMBiNOGHgvGMDv+s8YCyNg R/NR9Pjol723cKGnKmM5wUW8Ojti6wnVS/ippc8bNotbaNn9u36p24xNWNUUNuYpFSmd k1ZNRuV2UWhNtrV6tlpPEQhFPNe3xWSIyvqQ7rj0MrETc/5svgvtgHWzxbDJxPyLGXO1 5SYg== X-Gm-Message-State: AOAM530eqbLH9MLyb2y+M+lih3gBzcdsNB0bZRBLlup0kRu1c0PZ4+EM yfbJ/MlXvi8dnXevI3i6/gM= X-Received: by 2002:a17:906:26d7:: with SMTP id u23mr8155623ejc.210.1610295490235; Sun, 10 Jan 2021 08:18:10 -0800 (PST) Received: from ubuntu-laptop (ip5f5bfcff.dynamic.kabel-deutschland.de. [95.91.252.255]) by smtp.googlemail.com with ESMTPSA id ot18sm5851290ejb.54.2021.01.10.08.18.08 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Jan 2021 08:18:09 -0800 (PST) Message-ID: <0ad818b10110c4c383afbc2c39235a4f7f17f4c7.camel@gmail.com> Subject: Re: [PATCH 2/2] scsi: ufs: Protect PM ops and err_handler from user access through sysfs From: Bean Huo To: Can Guo , asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@codeaurora.org, ziqichen@codeaurora.org, rnayak@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com Cc: Alim Akhtar , Avri Altman , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , Nitin Rawat , Adrian Hunter , Bart Van Assche , Satya Tangirala , open list Date: Sun, 10 Jan 2021 17:18:05 +0100 In-Reply-To: <1609595975-12219-3-git-send-email-cang@codeaurora.org> References: <1609595975-12219-1-git-send-email-cang@codeaurora.org> <1609595975-12219-3-git-send-email-cang@codeaurora.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2021-01-02 at 05:59 -0800, Can Guo wrote: > + * @shutting_down: flag to check if shutdown has been invoked > + * @host_sem: semaphore used to serialize concurrent contexts > * @eh_wq: Workqueue that eh_work works on > * @eh_work: Worker to handle UFS errors that require s/w attention > * @eeh_work: Worker to handle exception events > @@ -751,7 +753,8 @@ struct ufs_hba { > u32 intr_mask; > u16 ee_ctrl_mask; > bool is_powered; > - struct semaphore eh_sem; > + bool shutting_down; > + struct semaphore host_sem; > > /* Work Queues */ > struct workqueue_struct *eh_wq; > @@ -875,6 +878,11 @@ static inline bool ufshcd_is_wb_allowed(struct > ufs_hba *hba) > return hba->caps & UFSHCD_CAP_WB_EN; > } > > +static inline bool ufshcd_is_sysfs_allowed(struct ufs_hba *hba) > +{ > + return !hba->shutting_down; > +} > + Can, Instead adding new shutting_down flag, can we use availible variable system_state? Thanks, Bean