Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3528928pxm; Mon, 28 Feb 2022 23:26:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8XF0O4NxMOt2NbBUiGRhBSwlb4A2fOU2XHUj64LOn79nFr/JK6qA7HmVfjX2amQg4aHdw X-Received: by 2002:a05:6a00:1516:b0:4be:3d3a:c6d0 with SMTP id q22-20020a056a00151600b004be3d3ac6d0mr25865738pfu.4.1646119605434; Mon, 28 Feb 2022 23:26:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646119605; cv=none; d=google.com; s=arc-20160816; b=DK8RWCgJ9KrlqqI6UFS5k9pRo8ZWQvWOobojOSkWQGfmu/T5QPRvpfcbNQEpMR/mZv p0hehK70pKT3JyPJU74HW2V5UiOczjwQosZoTH7/Hj/mrGPjYDX0Y2bI7Dq3KdvaGFyw IQdE6VBEJnHnPPzLkJMKO3R5N3mYJbZnKXviARrdO+rciDCPOfdpilAQwU2P11fPotsE LOVtlmjbBBUlGAmTcScakPuFdvYjObUaYivLUbk/e/paU04IOAqlltNCgAcGtuqPrGKa Y1iNFFaZH/YFUdyXhm/kAEafGDhw/T90LafK+LuvL9UCQ0Thplz5lWfbbwpwE2omtphA RBBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=8IqwMuZ8fxt+QmrdqHOlImG77CSzeOXAfU3F7s/g1es=; b=QO7Y3zP/+5XnCZu5nIsfogVrB7rxe17qHa3ks2zgVucihDTEvbUKgKl5SQHdkZeh/R Pqu6ZqnQHubFsdwu/bOHeg7vH1Okkjq8dyLtdu7cO+Wev9rw1n/FwixxtZvKOCFQ2Rwb L8AdG/VEMvz49CUgWSXeF6jodWNr0YTUXMQ4bGVkRD4SVuuYD7usbtdnKeAs34JEhj+0 U6oFgKmEji2l3UQgGd7Br7ZKazUYyQDBaFvOD5jvi2Y+q/sLxwJaefKx26BDdgqvU/Au Y7ipm0wm0bj1VE8maGe/bwzvOA9ikhyv4vyynXazKAvXrDiyq72Ak+bo+UXdOCqvSiBF oA3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Zt7ADjjg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e3-20020a63d943000000b003758cfb5bc5si11380404pgj.524.2022.02.28.23.26.30; Mon, 28 Feb 2022 23:26:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Zt7ADjjg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232691AbiCAGns (ORCPT + 99 others); Tue, 1 Mar 2022 01:43:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbiCAGnq (ORCPT ); Tue, 1 Mar 2022 01:43:46 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0C2348E7E for ; Mon, 28 Feb 2022 22:43:04 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id x5so20612539edd.11 for ; Mon, 28 Feb 2022 22:43:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8IqwMuZ8fxt+QmrdqHOlImG77CSzeOXAfU3F7s/g1es=; b=Zt7ADjjg4rQdQMZupIjoQnW8OZzkrW1QqynxdshmIEkct/PUWuc8mHmtaLMl7SRf4j O/SsyFxp+cXtdodgFZY1yMgZ2bgTQgu4U8POD6AExh1V8MJIq3bb7qef796sT4BUC6Vq 2dGy0L5SzrT/5p9DN1SjVbc8UkJUnWYEDpsOv6Fszv3rzZ728aXUFTHimB0CAxkBX4DX xrufVPSLR9vwBy1h/CSAOqSR+pgCZyQ+7DUcXmZjFeG9I0KcBRC82y7KxWo00HF556jR M4UWSK1tWyrR/CgjgF6TF8QOCgtuVLdDxoUX7rPxIEp1+gTuWTERDx1fKUxHvoWeI9qA 5XoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8IqwMuZ8fxt+QmrdqHOlImG77CSzeOXAfU3F7s/g1es=; b=oUjx4f9L07eijD7DsJ0Qo1VZ2AixIV0gRCZWMHVSIvHMkycOpatFlocZsztDZ7i0pU ePNZ3Q2Yp3ZHoPTbH6O4OvyUFGfkuL1d2ySE6i0xBhNb8WUgEKRdRjNCSImkgkwRha0Q TYLkM0HxnxFM/A6A3BVC78BftnZyClKgc1dBeZKnkJsOGwBPjDRy0raJIN3Y06KB+WRO l7a+6HAK0pwneksc0HxDILXZ10Rltjn2JH6WlD9tOABI2WmPqJQTt2Fjq1teT/CIjPZM RHctql4wq8u0wVu4UKZT9Rj1wgP70Ow6Qg8Jwrus7pXP5gMm2SBdetDwGRkrCsWdJgiy igWw== X-Gm-Message-State: AOAM531+56XWuSLUxCCLR8q0v017EU1k5zHnmUCUGwzlwvZs7tD+523R 8Skmkmd0Ehc6uwGXLE47tNAPP7Vdbveb+HElQ/rcLw== X-Received: by 2002:a05:6402:375:b0:404:c2be:3b8c with SMTP id s21-20020a056402037500b00404c2be3b8cmr22490537edw.247.1646116983110; Mon, 28 Feb 2022 22:43:03 -0800 (PST) MIME-Version: 1.0 References: <20220224054332.1852813-1-keescook@chromium.org> <202202232208.B416701@keescook> <20220224091550.2b7e8784@gandalf.local.home> <20220228232131.4b9cee32@rorschach.local.home> In-Reply-To: <20220228232131.4b9cee32@rorschach.local.home> From: Daniel Latypov Date: Mon, 28 Feb 2022 22:42:51 -0800 Message-ID: Subject: Re: [PATCH] binfmt_elf: Introduce KUnit test To: Steven Rostedt Cc: Kees Cook , Eric Biederman , David Gow , Alexey Dobriyan , =?UTF-8?B?TWFnbnVzIEdyb8Of?= , kunit-dev@googlegroups.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-18.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 28, 2022 at 8:21 PM Steven Rostedt wrote: > > On Mon, 28 Feb 2022 17:48:27 -0800 > Daniel Latypov wrote: > > > He also prototyped a more intrusive alternative to using ftrace and > > kernel livepatch since they don't work on all arches, like UML. > > Perhaps instead of working on a intrusive alternative on archs that do > not support live kernel patching, implement live kernel patching on > those archs! ;-) > > It's probably the same amount of work. Well, really, you only need to > implement the klp_arch_set_pc(fregs, new_function); part. Yeah, that's the only bit we'd need to get working. I called this out in "Open questions:" bit on https://kunit-review.googlesource.com/c/linux/+/5109 As for the amount of work, I know how to do KUnit-y things, I have no idea how to do livepatch things :) Also, we're not aiming for something as "magic" as the ftrace one. David's patch is here: https://kunit-review.googlesource.com/c/linux/+/5129 Here's a snippet from the example in that one: static int add_one(int i) { /* This will trigger the stub if active. */ KUNIT_TRIGGER_STATIC_STUB(add_one, i); return i + 1; } i.e. users just add this one macro in with and . It internally expands to roughly if () So it's all quite simple. But it'd definitely be interesting to try and get klp_arch_set_pc() working on UML if that's a possibility! Speaking from ignorance, I can see this either being somewhat simple or very painful. > > -- Steve