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 ACB60C433EF for ; Tue, 23 Nov 2021 05:17:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233607AbhKWFUu (ORCPT ); Tue, 23 Nov 2021 00:20:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbhKWFUa (ORCPT ); Tue, 23 Nov 2021 00:20:30 -0500 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8949CC061748 for ; Mon, 22 Nov 2021 21:17:23 -0800 (PST) Received: by mail-il1-x132.google.com with SMTP id w4so9325576ilv.12 for ; Mon, 22 Nov 2021 21:17:23 -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=Y6wA+fTxcw8TAoeh651HUjfstV6lKGvsFMZxmdYQsbE=; b=LU0ZvfU9vK5eZWidIvLRF/tW0j9fzVK2tqFxAN7l+MCYBDErEndqlom8GzkX1iU1ZS uS6TETBuFWQRgsAxfGPLv4tab5U1m0k/oX72iqRJtV2Xot7fpXVCgXQzZrsbp+JprHIK gaKJFZ6rNOSav8jZTRH/P+yWHKQi/NUkGm7A8e8HZyr0mGsnB3RNmSheBlOPl6iDA8o0 87EMLVR/0Ms9rV0IFJIGnPEL+TjVXX5YAKsTeFN+lupkfcM2CXFzfmE8ipI7I0UOwlOU SutZqO6K7EsNpssL0zIKdXie3Tsr0V0wrL4k0DbVN10XLcbYkga0GS3ePjm78qHkUV4n q/yw== 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=Y6wA+fTxcw8TAoeh651HUjfstV6lKGvsFMZxmdYQsbE=; b=EWvm8IODFQ9t3YibgYSimlCDCjmy9g7vX70PkOGEyckBBP64Jsdw8lqe+F/ad75MGZ piMjiv+/rxVgEKPtGDv0kpKrYZhcDMA+bN1Gf+776z8r+u580/TgbCDR47WGzvmPs3Il oqKPpctUjg05msLUbfyJcUnh1xy6PHS+EHYrtrfsxKE9eoziPO40pGXtEOcnVbqldlLU A4cnnJw66DryIvQ/HHmJQXBGaEayzX/gLb7xYjWryF1hFBpYklEh+73lvoNgZw3tL1XF a1y3+vpgduBC6ZXi6o36LLyAN5IEy97wfC30vfcuOzfLGutTjEqJoN6LmjXNUnm7AUW7 v21A== X-Gm-Message-State: AOAM533qotAOK9YHguAiCukk9p5FhbrWFWA2ASY31z36zaOMheQo18A5 C8VbZ7+WIOtC6hv8nV8FeBv3y/SR2AE3sttS6EXzNw== X-Google-Smtp-Source: ABdhPJym9u5SF1PXPJzAgk/mV0cTda0xvKfSqcK5DnCV2QotJzY53LEERFeLrxQwzh5W8F2ocMM0QeOScZZbOHSMuT4= X-Received: by 2002:a92:2012:: with SMTP id j18mr1185759ile.146.1637644642772; Mon, 22 Nov 2021 21:17:22 -0800 (PST) MIME-Version: 1.0 References: <20210922061809.736124-1-pcc@google.com> In-Reply-To: From: Peter Collingbourne Date: Mon, 22 Nov 2021 21:17:11 -0800 Message-ID: Subject: Re: [PATCH] kernel: introduce prctl(PR_LOG_UACCESS) To: Cyrill Gorcunov Cc: Catalin Marinas , Will Deacon , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Thomas Gleixner , Andy Lutomirski , Kees Cook , Andrew Morton , Masahiro Yamada , Sami Tolvanen , YiFei Zhu , Colin Ian King , Mark Rutland , Frederic Weisbecker , Viresh Kumar , Andrey Konovalov , Gabriel Krisman Bertazi , Balbir Singh , Chris Hyser , Daniel Vetter , Chris Wilson , Arnd Bergmann , Dmitry Vyukov , Christian Brauner , "Eric W. Biederman" , Alexey Gladkov , Ran Xiaokai , David Hildenbrand , Xiaofeng Cao , Thomas Cedeno , Marco Elver , Alexander Potapenko , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Evgenii Stepanov Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 21, 2021 at 11:30 PM Cyrill Gorcunov wrote: > > On Tue, Sep 21, 2021 at 11:18:09PM -0700, Peter Collingbourne wrote: > > This patch introduces a kernel feature known as uaccess logging. > > With uaccess logging, the userspace program passes the address and size > > of a so-called uaccess buffer to the kernel via a prctl(). The prctl() > > is a request for the kernel to log any uaccesses made during the next > > syscall to the uaccess buffer. When the next syscall returns, the address > > one past the end of the logged uaccess buffer entries is written to the > > location specified by the third argument to the prctl(). In this way, > > the userspace program may enumerate the uaccesses logged to the access > > buffer to determine which accesses occurred. > ... > > diff --git a/include/linux/sched.h b/include/linux/sched.h > > index e12b524426b0..3fecb0487b97 100644 > > --- a/include/linux/sched.h > > +++ b/include/linux/sched.h > > @@ -34,6 +34,7 @@ > > #include > > #include > > #include > > +#include > > #include > > > > /* task_struct member predeclarations (sorted alphabetically): */ > > @@ -1487,6 +1488,8 @@ struct task_struct { > > struct callback_head l1d_flush_kill; > > #endif > > > > + struct uaccess_buffer_info uaccess_buffer; > > + > > Hi, Peter! I didn't read the patch carefully yet (will do once time permit) > but from a glance should not this member be under #ifdef CONFIG_UACCESS_BUFFER > or something? task_struct is already bloated too much :( Yes, I've now added an ifdef here (previously I had the ifdef inside the struct uaccess_buffer_info, but I think this would still leave some space due to C struct layout rules). > > > + case PR_LOG_UACCESS: > > + if (arg5) > > + return -EINVAL; > > + error = uaccess_buffer_set_logging(arg2, arg3, arg4); > > + break; > > Same here (if only I didn't miss something obvious). If there is no support > for CONFIG_UACCESS_BUFFER we should return an error I guess. The uaccess_buffer_set_logging (now uaccess_buffer_set_descriptor_addr_addr) function is defined to return -EINVAL if CONFIG_UACCESS_BUFFER is not defined. Peter