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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D093C433FE for ; Wed, 16 Nov 2022 04:34:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 89FB56B0071; Tue, 15 Nov 2022 23:34:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 828EF6B0072; Tue, 15 Nov 2022 23:34:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6CA656B0073; Tue, 15 Nov 2022 23:34:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 58E6B6B0071 for ; Tue, 15 Nov 2022 23:34:53 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 23789120669 for ; Wed, 16 Nov 2022 04:34:53 +0000 (UTC) X-FDA: 80138040066.18.26AA466 Received: from mail-vk1-f175.google.com (mail-vk1-f175.google.com [209.85.221.175]) by imf16.hostedemail.com (Postfix) with ESMTP id C498D18000A for ; Wed, 16 Nov 2022 04:34:52 +0000 (UTC) Received: by mail-vk1-f175.google.com with SMTP id bk51so7429112vkb.4 for ; Tue, 15 Nov 2022 20:34:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=FmxnDIRF3z4tVcQHy0ykyvRCfKyX9vqd9nq5zuayq/o=; b=EQyJmb5NzuW7Lrmx1UMxwNMSc7k121+UGTlaW+fgEO57T29KUzUO0pmfXzmd8y6CEX Jb3QyrZ9WjcPq86aZ8yqUrw5KQDgEPoG8QhlKNlUADgwOfATxqgKrEr6LqoSYsM6st9F 1YVMfFr3J7Rv1hNFVw7rtRRlXDXgV+gO7KxZyMIEDI6sDa0iQZA9CeGZkVRURnldsycn 9zWJcqg8TV3Eq/6Y3L/D5LnkBqDr1ilu/BIrAUOpJgd28mtis4ijip0tlVxLeNAe1btT jTuwD3azfLPaYk1AtMV8e2lR0u5IFvrMzqMbVXeMNWV2jztW9hZGf3dGowpd6wgudenl 3RWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FmxnDIRF3z4tVcQHy0ykyvRCfKyX9vqd9nq5zuayq/o=; b=5UDnYz8m2qTntuAubiES0vfMHIoFjZVm+sU+e4js5yJ8KSTIQhGCushDJuA9sFSLyL dWox6paZX0MeECnvo6jCfFmaZTT6b5H8551kYkkjcx383t1PwU+EPOOjA4p9eEOU2xaq wFFXDuHWTI8OAgS/SHOjHK456EqW4LsRwNfIYkPa/4p42E+hYXlvMkMhiKy1AWLmoVnG 5VDOv6lTsr+BF10osttP0sHWcpQ9U5ZyzeHyfZcfKtMaCBUmUEUnQHgPibOflzDSnhNd bK4WlVXnygY58qcO0Y3ahEgW354qyAFr/JVhyZ2/fciJx/cVOAw3o6m9aB8mLvuov/g8 IeVA== X-Gm-Message-State: ANoB5plwRKDQN6mc51N8ns1mwxF226QcmqLLk4Vf8N9WqhTGDjKMw9B5 DmOO+yGhVA6vJtOf8Q+oxNU0bwJ8VPp4luMCZOs6Pw== X-Google-Smtp-Source: AA0mqf71S572lwU6nUh1KCBE2iEeZgtF1t/Kg31iPNqx35YME43NQlTnmOzGQHbpzsQxj91vADhe3iC/FCPOG1OhHDc= X-Received: by 2002:a05:6122:d06:b0:3bb:d1fb:15f2 with SMTP id az6-20020a0561220d0600b003bbd1fb15f2mr11898407vkb.37.1668573291838; Tue, 15 Nov 2022 20:34:51 -0800 (PST) MIME-Version: 1.0 References: <20221106021657.1145519-1-pedro.falcato@gmail.com> <202211061948.46D3F78@keescook> In-Reply-To: <202211061948.46D3F78@keescook> From: David Gow Date: Wed, 16 Nov 2022 12:34:40 +0800 Message-ID: Subject: Re: [PATCH] fs/binfmt_elf: Fix memsz > filesz handling To: Kees Cook Cc: Pedro Falcato , linux-kernel@vger.kernel.org, linux-mm@kvack.org, sam@gentoo.org, Alexander Viro , Eric Biederman , linux-fsdevel@vger.kernel.org, Rich Felker , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668573292; a=rsa-sha256; cv=none; b=VJxLQ56Xkldo2Ot/Oxj0MmtYrf4BKiKbbex/wNoC1p9Zft+cykOMO1bQkQgcgDlwMRKWyG rv/bfnM9W9p9y6rOlNjMe/yQmmiRjpcC4dAMK1lbYkhbLt2rKcDLsWH17EZ3Ec2Cnln4C8 GYcHyvATfdUa5ReUkuhttE5z6aGToV0= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=EQyJmb5N; spf=pass (imf16.hostedemail.com: domain of davidgow@google.com designates 209.85.221.175 as permitted sender) smtp.mailfrom=davidgow@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668573292; h=from:from:sender: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:dkim-signature; bh=FmxnDIRF3z4tVcQHy0ykyvRCfKyX9vqd9nq5zuayq/o=; b=DkhWyWEt8oRl6auk+hdSVrsVuYFlrGARZcvdiiZMhSR5liVggw34EeHFjGQI1gt6FE6zWR 0eH7fxys851NJOZVcWR+B2PTuaXa6+7vuo4M45hKUVbIyl3uN1OBjBJv/tyX7aZgSsxj2L Prha0OFZCiwGhSf7njaLUe9HS0TZhZs= X-Rspam-User: X-Stat-Signature: egsjs91idxt4gpqbx3y7kwxpb8c5ckma X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: C498D18000A Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=EQyJmb5N; spf=pass (imf16.hostedemail.com: domain of davidgow@google.com designates 209.85.221.175 as permitted sender) smtp.mailfrom=davidgow@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1668573292-68953 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Nov 7, 2022 at 11:59 AM Kees Cook wrote: > > On Sun, Nov 06, 2022 at 02:16:57AM +0000, Pedro Falcato wrote: > David, has there been any work on adding a way to instantiate > userspace VMAs in a KUnit test? I tried to write this myself, but I > couldn't figure out how to make the userspace memory mappings appear. > Here's my fumbling attempt: > https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/log/?h=devel/kunit/usercopy > > I really wish KUnit had userspace mapping support -- I have a bunch of > unit tests that need to get built up around checking for regressions > here, etc. Hi Kees, Sorry the the delayed response! Alas, my attempts to get this to work haven't been much more successful than yours. It's definitely something we'd like to support, but I confess to not knowing enough about the mm code to know exactly what would be involved. The workaround is to load tests as modules, and use something like Vitor's original patch here: https://lore.kernel.org/all/20200721174036.71072-1-vitor@massaru.org/ Basically, using the existing mm of the module loader. Adapting those changes to your branch (and fixing a couple of back-to-front KUnit assertions) does work for me when built as a module, in an x86_64 vm: root@slicestar:~# modprobe usercopy_kunit [ 52.986290] # Subtest: usercopy [ 52.986701] 1..1 [ 53.246058] ok 1 - usercopy_test [ 53.246628] ok 1 - usercopy But getting it to work with built-in tests hasn't been successful so far. I wondered if we could just piggy-back on init_mm or similar, but that doesn't seem to work either. So, in the short-term, this is only possible for modules. If that's useful enough, we can get Vitor's support patch (or something similar) in, and just mark any tests module-only (or have them skip if there's no mm). Because kunit.py only runs built-in tests, though, it's definitely less convenient. Cheers, -- David