From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5921BC4332F for ; Sun, 13 Nov 2022 16:58:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235252AbiKMQ6b (ORCPT ); Sun, 13 Nov 2022 11:58:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235014AbiKMQ60 (ORCPT ); Sun, 13 Nov 2022 11:58:26 -0500 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 751D724F; Sun, 13 Nov 2022 08:58:24 -0800 (PST) Received: from zn.tnic (p200300ea9733e71a329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e71a:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id D58EF1EC008F; Sun, 13 Nov 2022 17:58:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1668358702; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=eB/hC3tGZeJADbPXtdKZGPPgu/jWHckff1IDi4hbfsg=; b=Ji4HYYYbpsV4WMX6qTt/HajNGQTw5Ysj4UBgFSfemcuXmmV3RTigUJS37NepjYccA4XA0S RCkwnsSQab6YU3XqZse5KIhGkKiAA5f0AEnjXjmiytImR0eICK361NCiJi+7zJ0fAzToCE fVOtbbnVzNiMcBN72B83JjFBbFv31gU= Date: Sun, 13 Nov 2022 17:58:17 +0100 From: Borislav Petkov To: "Joseph, Jithu" Cc: "gregkh@linuxfoundation.org" , Thiago Macieira , "Luck, Tony" , "hdegoede@redhat.com" , "markgross@kernel.org" , "tglx@linutronix.de" , "mingo@redhat.com" , "dave.hansen@linux.intel.com" , "x86@kernel.org" , "hpa@zytor.com" , "Raj, Ashok" , "linux-kernel@vger.kernel.org" , "platform-driver-x86@vger.kernel.org" , "patches@lists.linux.dev" , "Shankar, Ravi V" , "Jimenez Gonzalez, Athenas" , "Mehta, Sohil" Subject: Re: [PATCH v2 12/14] platform/x86/intel/ifs: Add current_batch sysfs entry Message-ID: References: <20221021203413.1220137-1-jithu.joseph@intel.com> <20221107225323.2733518-1-jithu.joseph@intel.com> <20221107225323.2733518-13-jithu.joseph@intel.com> <5e65889d-d68c-b29d-6cea-7b4ce4c87b4a@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <5e65889d-d68c-b29d-6cea-7b4ce4c87b4a@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 13, 2022 at 08:41:47AM -0800, Joseph, Jithu wrote: > Do you think it is better to restrict filename input to confirm > to ff-mm-ss-xy. format rather than accepting any string and > treating it as a file-name and trying to load it, if it is present ? Yap, that way you pre-filter filenames. Yeah, the header checks *must* absolutely happen too but it would be a simple first test. Also, you can check for: ff-mm-ss-X. where X is a [0-9]+ of arbitrary length and this way won't have the artificial 256 limit you have now. > (Given that, before loading, We do intel_find_matching_signature(), > which validates if the signature/pf entries in header confirms to the > machine we are on before loading) > > We did accepting file-name as input before [1] (except for validating > if the filename confirms to ff-mm-ss format) Yeah, except now you want to do multiple sets of scan files. But yeah, you can extend the interface even more: echo /sysfs/file * if f/m/s matches, you execute if still within the timeout, you return -EAGAIN from current_batch_store() to tell userspace, take a nap and try again. * if the f/m/s doesn't match you return -EINVAL to say, wrong filename, try the next one. And this way, the user script can simply look at the retvals and act accordingly - it won't even need to parse dmesg or wnatnot. For example. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette