Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4132432imu; Mon, 10 Dec 2018 13:44:13 -0800 (PST) X-Google-Smtp-Source: AFSGD/XObm5DlWBJIkO+GZwh67KQJ4x3Z+ss3xYcu2xe/oVZT6Cxybotbd9n901MPg+ahXpuDbCo X-Received: by 2002:a65:5286:: with SMTP id y6mr7592478pgp.439.1544478253784; Mon, 10 Dec 2018 13:44:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544478253; cv=none; d=google.com; s=arc-20160816; b=sMUXLz7AFKslGqsx0jcBe0N8B/8HJgt3xOiyd+bt8v5UgnQWRvGU5znoqfOPGHd3uw 7VMm52I0NmBIfllLNOHVjgnElUfq2D+oT+zOLPOPWNHV6cooeZIY/uskglKfxFvH//G2 kTPpCTCW38u62aIG277XeS+EL4GW+mLZyrzFGLBhutXJulsf5ornrQVMfgiHUrWKviL2 YhWyFRr55fcQSQwl+MKmebbZn6CaZUCAdRulaj2H0C/GIt0KXXEED5n5wd8qWdqztC3u d49hF2GX5X5f9hDmf/Ax7w07qdUntDupyjneU3sFSoT9tw/BzoL1jRGHY4kQh2ElYjPM 8paA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=jCy5Tv4uXnC6ba1oSHKCMhsLjt6pkdJOY8hu64I3lmw=; b=yq6vl0TNJJm+pgy+di/+a1FSWURaD9VtYTN805IqsjV+Wrn8uzSqXp6NpokcAjtK/F YND+MXMRGV7j1mMIswfZehSzZIzGk7Lam/82SkJl5olrg4VtHQkVuXREf+UfSV4c3LTC L3QMWusLFut2/I9rHnRkgKGtkswmrW6HkGMFJsP4ccbe59InsHCauTl3L7sTMS5g5f8x Fwjq/JE6CFMvWifwSUnIztJSqS/qAeD4v6WEzh4tg7tHLy5bU+jCC1hHQZHmg8bbXoEn SLWEmhXArH6qzDSgPzgvWqHI5jdguvXL3jVuLUknpF1JkEoGUhapRi93ZCPaqEmX6Llc fOhA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q18si10691441pls.30.2018.12.10.13.43.58; Mon, 10 Dec 2018 13:44:13 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728598AbeLJUmQ (ORCPT + 99 others); Mon, 10 Dec 2018 15:42:16 -0500 Received: from mga11.intel.com ([192.55.52.93]:46031 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727598AbeLJUmP (ORCPT ); Mon, 10 Dec 2018 15:42:15 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Dec 2018 12:42:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,339,1539673200"; d="scan'208";a="117229612" Received: from rchatre-mobl.amr.corp.intel.com (HELO [10.24.14.96]) ([10.24.14.96]) by orsmga002.jf.intel.com with ESMTP; 10 Dec 2018 12:42:14 -0800 Subject: Re: [PATCH] x86/resctrl: Fix rdt_find_domain() return value checks To: Borislav Petkov Cc: tglx@linutronix.de, fenghua.yu@intel.com, tony.luck@intel.com, jithu.joseph@intel.com, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org References: <20181210191311.GC5482@zn.tnic> From: Reinette Chatre Message-ID: <40422756-cef4-38b1-8554-c99e7bcb7765@intel.com> Date: Mon, 10 Dec 2018 12:42:14 -0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181210191311.GC5482@zn.tnic> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Boris, On 12/10/2018 11:13 AM, Borislav Petkov wrote: > On Wed, Nov 28, 2018 at 10:20:27AM -0800, Reinette Chatre wrote: >> rdt_find_domain() may return an ERR_PTR(), NULL, or a pointer to struct >> rdt_domain. It is thus required that the return value be checked for the >> possibility of an ERR_PTR as well as NULL. > > Well, it returns ERR_PTR(id) but code which uses ERR_PTR passes in an -E > value, for example ERR_PTR(-EINVAL) or so, and not an id. > > And that might work now if id fits within that MAX_ERRNO range - I'm > looking at include/linux/err.h - but that's still fragile. > Thank you for catching this. It does seem as though things work at this time since rdt_find_domain() contains: if (id < 0) return ERR_PTR(id); and from what I can tell the only possible negative value of id is -1. As you note, this is fragile. Additionally the error, if intending to use -E values, does not reflect the error (since -1 would mean EPERM). Would you be ok if the above is changed to if (id < 0) return ERR_PTR(-ENOENT); as part of this patch? Looking at rdtgroup_mondata_show() is does seem as though ENOENT is the actual intended error value, although ENODEV could perhaps also be considered since such a result reflects that a particular cache instance could not be found. Thank you! Reinette