Received: by 2002:a4a:301c:0:0:0:0:0 with SMTP id q28-v6csp1171994oof; Tue, 25 Sep 2018 09:10:06 -0700 (PDT) X-Google-Smtp-Source: ACcGV60U/apJC8jt+H12QFIvhT0PTDLI52NzY8jxpIP1rQU2qY6Dubb+R5dZH54UIFzFPAdl8Ein X-Received: by 2002:a17:902:d893:: with SMTP id b19-v6mr1926100plz.51.1537891806165; Tue, 25 Sep 2018 09:10:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537891806; cv=none; d=google.com; s=arc-20160816; b=RPdKJzGlpo2us4i67myJ9BIrDUom14JY4eZHrqQOdxNxrsxvki9LawTJbD/SvCRsge p9Nrpngtj1KnsmD+e5eZ/S5Cz1A2ShL49XiyMcTR2LOX/+lgwcM7kOXbEwbAXo5ZCU+8 rc+gnYqVmNYS10wzcj/jyN5BspIHUMjBiUOSY17/b8h33RSogwrV83RLqkUiHCxKpcIB DeUK7QrAyFstxvf57v2AiWhfJDsC0el3Kd/u1BAOtwXU7frIUbnzHUWjFFgemS3GeqB0 ynr8zmzjUITp95Ca9NbVk/vV/lW0+FEuGURL8GEssdTBbzys1Vifs66AjZrZpvrYBCkB uUMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date; bh=tjqav8il6bNPwABX38MsZzp8yCAdKN+AUYIEsyjoDsc=; b=QUNKf+bDN+36a/r3xVWwWMla0maFbL8hqRpmgVNI88Ixg5lKMs4XC2kYd5cj1gG8Al L0uH7mWrEndCSQl1cFhsfmCdV0BpWmXQL5Tr+EEpW57Ubzgmhb9sx7MyOkWtSBn3QC+n eMf72PK5wq9R1Zh9oY22JeSOlfNGQC5GFsoDrXOooU+iR26oDIUYdW0SdlX8P6On1+Hx o95WYmcgOBGQH7LVIBsJ0mg3uM8w5T1WwuOl9atKIdSRO3zfHkWcevlnIbqBgLBtMXCk DM8pWoFQeRT0ySOsFkVZvvcBhXnxfA3nBpgVe8nb38A5YEeaPuOnk47NhWvhoa3ZZSN1 KAQg== ARC-Authentication-Results: i=1; mx.google.com; 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 p14-v6si2715972plo.363.2018.09.25.09.09.49; Tue, 25 Sep 2018 09:10:06 -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; 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 S1729322AbeIYWRz (ORCPT + 99 others); Tue, 25 Sep 2018 18:17:55 -0400 Received: from g9t1613g.houston.hpe.com ([15.241.32.99]:32911 "EHLO g9t1613g.houston.hpe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728776AbeIYWRz (ORCPT ); Tue, 25 Sep 2018 18:17:55 -0400 Received: from g2t2352.austin.hpe.com (g2t2352.austin.hpe.com [15.233.44.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by g9t1613g.houston.hpe.com (Postfix) with ESMTPS id EB8AA63149; Tue, 25 Sep 2018 16:09:43 +0000 (UTC) Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2352.austin.hpe.com (Postfix) with ESMTP id 2BBA2B2; Tue, 25 Sep 2018 16:09:43 +0000 (UTC) Received: from anatevka.americas.hpqcorp.net (anatevka.americas.hpqcorp.net [10.34.81.6]) by g2t2360.austin.hpecorp.net (Postfix) with ESMTP id 7CC9049; Tue, 25 Sep 2018 16:09:42 +0000 (UTC) Date: Tue, 25 Sep 2018 10:09:42 -0600 From: Jerry Hoemann To: Shuah Khan Cc: erosca@de.adit-jv.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] selftests: watchdog: Add gettimeout and get|set pretimeout Message-ID: <20180925160942.GA25620@anatevka.americas.hpqcorp.net> Reply-To: Jerry.Hoemann@hpe.com References: <1537570526-65241-1-git-send-email-jerry.hoemann@hpe.com> <0c6376ec-a3f4-7798-8f30-829480c41f79@kernel.org> <20180924014750.GA22296@anatevka.americas.hpqcorp.net> <1c4e6b40-dc4e-5706-0a31-1741ba19ca09@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 25, 2018 at 09:50:18AM -0600, Shuah Khan wrote: > >>> Also can you run this test as normal user? > >> > >> No. Must be run as root to open /dev/watchdog. When /dev/watchdog is opened, the > >> WD is started and if not updated properly, the system will crash. > > > > Hmm. I don't understand why the system would panic if non-root user can't open the > > device, at least in the context of this test. > > > > fd = open("/dev/watchdog", O_WRONLY); > > > > if (fd == -1) { > > printf("Watchdog device not enabled.\n"); > > exit(-1); > > } > > > > > > Shouldn't it just exit based on the code above? > > > >> > > > >> "cat /dev/watchdog" is one of my favorite ways to crash a system. :) :) > > > > That doesn't sound great, if a non-root user can bring the system down!! > > > > This got me concerned enough that I tried this with softdog. It behaved just > the way I expected it. > > cat /dev/watchdog > cat: /dev/watchdog: Permission denied > > Running the test as non-root does the following as per the current logic. > > watchdog-test -b > Watchdog device not enabled. > > I think this logic could be improved to detect that a non-root user is running > the test and print appropriate message. > > However, I am not seeing the behavior you are describing that "cat /dev/watchdog" > panics the syste. Did you mean running a root which is expected unless you terminate > before the timeout? If you are seeing this as non-root user on you system, the > watchdog driver could be suspect. > > thanks, > -- Shuah Sorry, for misunderstanding. Let me rephrase: When you asked if the test can be run as a normal user:: No. The test must be run as root to open /dev/watchdog as the permission on /dev/watchdog allow only root to open it. The reason that we only allow root to open /dev/watchdog is that it is trivial to crash the system. Just open /dev/watchdog and don't update the watchdog. One of my favorite ways to crash the system is to as root "cat /dev/watchdog." -- ----------------------------------------------------------------------------- Jerry Hoemann Software Engineer Hewlett Packard Enterprise -----------------------------------------------------------------------------