From patchwork Thu Mar 16 00:30:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ackerley Tng X-Patchwork-Id: 70525 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp204731wrt; Wed, 15 Mar 2023 17:34:57 -0700 (PDT) X-Google-Smtp-Source: AK7set8oUutV8ZxFXRMwl2VsTG+I7/u1UyqqM482vvSaSb6nbP6REwqiRm4uIQQZns/bT5me+rXr X-Received: by 2002:a17:903:1107:b0:19e:b2f3:e8c4 with SMTP id n7-20020a170903110700b0019eb2f3e8c4mr1566968plh.25.1678926897427; Wed, 15 Mar 2023 17:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678926897; cv=none; d=google.com; s=arc-20160816; b=I0hsYbgoqkzONUimFQz4mkOasXint+MJzFvkIVFAeNgbj2NU0zvseem06Ae353c5jd P6qz4G+DdVtkBq7QCWwseiq4I/E0htFRUUIcUrbkWxkTdbkoxOIuazEkKNlpiy43qwGq ZgMWTxFG2phR0tLDNqzDrpFmaSVCH+mNqRLS02kcIpO/aB9GjaRXGCxX2mX47ggqLOEg IfGZO4cNN7Ewh8u5G/Ua+HOXUp+8UZ1Cij9VOA3hTGSD0ANZpQ+9c/vZvIx0ThrgS+yn ZLVxIeqYrrgGNEmYRm60yw3hvbbQWr+6+12keRRRZmfo2f+KsFodFIzyFDnLRk1px2qK 372Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=vx2+K6b7VucsfYU5uvwShdem3MP0VCFQdKNh537WPsg=; b=mQufiKQjHtdAi0+/1/4hjyc11y9yxo24keLsN+S9wSEfSSvagJwq8Rwk0kpIG/XW7s uvwwZavXTtQcGFSX+yQUlH19+97YPdPKe/nH38rbgbKnMmIouEyHr6BuwxJSKPqE+jsG jsCILSra5gkh3sWzBDslSYsz3+QdM+8gDIkK0bCXqPi7No5OqWZII3NIVLk/vjcbtpoi /O8z7bJDwFWwA67sDIR8xOKRHdHyemV5fRXTqlRF8VfVZt+5A0OwKeVwMekTavD2NePO 9NJsyAMdpP6piGtFoEN3wMjjN+l11H2ZZSjK22zSVru8SEbTKt3PONhJIqNEbQjFIC7A PR4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PAaXwSJq; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jl17-20020a170903135100b0019edb3d20f1si6007753plb.154.2023.03.15.17.34.42; Wed, 15 Mar 2023 17:34:57 -0700 (PDT) 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=PAaXwSJq; 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 S233083AbjCPAbi (ORCPT + 99 others); Wed, 15 Mar 2023 20:31:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233126AbjCPAb3 (ORCPT ); Wed, 15 Mar 2023 20:31:29 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7D399F20F for ; Wed, 15 Mar 2023 17:31:19 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id y31-20020a056a001c9f00b00623268e040dso176661pfw.7 for ; Wed, 15 Mar 2023 17:31:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678926678; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=vx2+K6b7VucsfYU5uvwShdem3MP0VCFQdKNh537WPsg=; b=PAaXwSJqPjUc6R/biIaCW2VNIfg9P921yoYdsBglXW7n/3lysnZkeEeswRZxCHBdd2 vae46IBUMuPrhA/m6sIKIzqdGOnQo5Ax7q3XOoZhIMO7H4xC0VbFQ0N3vE+qhGQUMHzu kPA+f6sp7rqp+TQqvoN2RVgjN8fnA/s8vq6Qc0ND26uA1J32QTIzKCh5QE6EZ2HKVyvQ j5NA1EYtTCtaS4iuVqchmK8CE1Gi+C6RcXJmBHwvadsPdAFJPwZbs86of6yw4m2yRstH qut3sHXQ3PqToSUKXfBRc1s9T+WqYiB5itYUbgh+khi4BVYb6F2EdusOJNoVl2aI0MUq SNww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678926678; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vx2+K6b7VucsfYU5uvwShdem3MP0VCFQdKNh537WPsg=; b=fAJ6ne+jH20fODIvU+35ztN4716iUytmTmnYc7/q3dBfFyqTQgiK/j3kzuvztj7unb XiAnQvWHR9Bb2DTPP54Lh00jXlrb94qhSRc+rYFz6KIgf+yRV/ugmEFD+g5DEnENZJ/9 TemSvXUiklC53xbgYFjAfcb+RHwuLY/jG+/YChboluiS+/X+vE8iZBZvcKeKns1s5/yl 06AorRDsaSkCvjIDH+sPMIJkvum4u9vE9wlDJXZpXdR9PEbZg9b0wRHWwRu9sK4S9x14 GEQr1LlQjH5O7ZYlRgK8CeJ0rupJyNH1feguixFlkiu88B+er501OHy8kwndBSYZxjnG YT0w== X-Gm-Message-State: AO0yUKVQiafOHAw6V5dGYKMvF+m51pwClf3BS4jsIiZ/NqhS+IPipcJo X7rs1rkNDSNK0iIYG4KX5BCiv0q6oId/XpuzFg== X-Received: from ackerleytng-cloudtop.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1f5f]) (user=ackerleytng job=sendgmr) by 2002:a05:6a00:23d6:b0:625:cf6d:b272 with SMTP id g22-20020a056a0023d600b00625cf6db272mr580538pfc.6.1678926678685; Wed, 15 Mar 2023 17:31:18 -0700 (PDT) Date: Thu, 16 Mar 2023 00:30:55 +0000 In-Reply-To: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.40.0.rc2.332.ga46443480c-goog Message-ID: <75eba82a2666b0caa96ed0484a713037045ed114.1678926164.git.ackerleytng@google.com> Subject: [RFC PATCH 02/10] KVM: selftests: Test that ftruncate to non-page-aligned size on a restrictedmem fd should fail From: Ackerley Tng To: kvm@vger.kernel.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, qemu-devel@nongnu.org Cc: aarcange@redhat.com, ak@linux.intel.com, akpm@linux-foundation.org, arnd@arndb.de, bfields@fieldses.org, bp@alien8.de, chao.p.peng@linux.intel.com, corbet@lwn.net, dave.hansen@intel.com, david@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, hpa@zytor.com, hughd@google.com, jlayton@kernel.org, jmattson@google.com, joro@8bytes.org, jun.nakajima@intel.com, kirill.shutemov@linux.intel.com, linmiaohe@huawei.com, luto@kernel.org, mail@maciej.szmigiero.name, mhocko@suse.com, michael.roth@amd.com, mingo@redhat.com, naoya.horiguchi@nec.com, pbonzini@redhat.com, qperret@google.com, rppt@kernel.org, seanjc@google.com, shuah@kernel.org, steven.price@arm.com, tabba@google.com, tglx@linutronix.de, vannapurve@google.com, vbabka@suse.cz, vkuznets@redhat.com, wanpengli@tencent.com, wei.w.wang@intel.com, x86@kernel.org, yu.c.zhang@linux.intel.com, Ackerley Tng X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760482450443113789?= X-GMAIL-MSGID: =?utf-8?q?1760482450443113789?= Signed-off-by: Ackerley Tng --- tools/testing/selftests/vm/memfd_restricted.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/testing/selftests/vm/memfd_restricted.c b/tools/testing/selftests/vm/memfd_restricted.c index 43a512f273f7..9c4e6a0becbc 100644 --- a/tools/testing/selftests/vm/memfd_restricted.c +++ b/tools/testing/selftests/vm/memfd_restricted.c @@ -38,6 +38,11 @@ static void test_file_size(int fd) { struct stat sb; + if (!ftruncate(fd, page_size + 1)) { + fail("ftruncate to non page-aligned sizes should fail\n"); + return; + } + if (ftruncate(fd, page_size)) { fail("ftruncate failed\n"); return;