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 4668DC433FE for ; Thu, 24 Mar 2022 21:45:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345641AbiCXVqc (ORCPT ); Thu, 24 Mar 2022 17:46:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230341AbiCXVqa (ORCPT ); Thu, 24 Mar 2022 17:46:30 -0400 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 324A3B7166 for ; Thu, 24 Mar 2022 14:44:57 -0700 (PDT) Received: by mail-io1-xd36.google.com with SMTP id e22so6948246ioe.11 for ; Thu, 24 Mar 2022 14:44:57 -0700 (PDT) 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=NtG3L3i2VNWzLKZCzuXCjQJQZ/iQPSa3QxfocCII+yI=; b=QiXk2bRrt9r2iy2pw39Ur0S1CksPSEVIavay+B5XCLlr32bHYrl+Jg7S1Wz9sJJddl SfdJh5KvOpCXlLl6D0qlljbm2QqG1ZimdlJGZ+kY9v0tqLOFLckFYG0DIgSDejmgHFOu rvJt10zs3T+Zi/e0PitYFXusD6ngNFenflicfM+z7BGnOC4QWS34JsIgWTg7/zkzy/ce 7yxmWbt6nH+726Ctq2wDyguUw9/BW1sCSX+QZ396esY35eMesUxgt4VlPFEdEaDT7vkL 8gnnaadz7PnCccOhffngbcdUOLtLr14uCeS7R2+XRp2J/I3wNU3R3yqCdjO2F3zsGKm6 uu3A== 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=NtG3L3i2VNWzLKZCzuXCjQJQZ/iQPSa3QxfocCII+yI=; b=DoBoa3BLwpAI4YjlQPcjrAFyN3BxLTbS8mA58/bIgBEdqWGboTXg1eg7MZkLlx75yY yXh+UnKy88M3vrRKpWvHsbNEpBTTst4Zp8+KKh9LD7xp9gNt5GYpucH6SnYnhyI/WihF qOkMPvLq5RkQj1Ld1N9dbhWIx7e/RSrBY8/O1Klm2FbMOF/rPM2i11sWadE2e3nXBCPC ugEoBvc2FI/BYOoq97r6BKlThLmwdUw7qh2f0xWWYzAOSXhkyuUdq5xLD0t1wo+iD2vY w46vwb0AQ4ewQPdg5XH3R3LTz8aUndL4c4CSOIKjxX7gj2Ttsoa3jjhwRvt9fkpXYyGC Ap/A== X-Gm-Message-State: AOAM530yd2NcUoI15+wP1tlL4/s47j3wIlaVURjidIwR7veV4FnJEcrE as+Nqyi7NHXdjH4/Xs01JU8oSo/e/eDocOwTj1So1Q== X-Google-Smtp-Source: ABdhPJzWHqISwWQ+GxG0Zg2dYghqEE6/RmqQZ/aiWq9FM5RxmFzYXqerGBEFOf6FUUsx7Gpn4GC0i7gIFHccilOldj8= X-Received: by 2002:a05:6602:1493:b0:649:1890:cffd with SMTP id a19-20020a056602149300b006491890cffdmr3907876iow.167.1648158296431; Thu, 24 Mar 2022 14:44:56 -0700 (PDT) MIME-Version: 1.0 References: <20220324210909.1843814-1-axelrasmussen@google.com> In-Reply-To: From: Axel Rasmussen Date: Thu, 24 Mar 2022 14:44:20 -0700 Message-ID: Subject: Re: [PATCH] mm/secretmem: fix panic when growing a memfd_secret To: Matthew Wilcox Cc: Andrew Morton , Mike Rapoport , Linux MM , LKML , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 24, 2022 at 2:33 PM Matthew Wilcox wrote: > > On Thu, Mar 24, 2022 at 02:09:09PM -0700, Axel Rasmussen wrote: > > This patch avoids the panic by implementing a custom setattr for > > memfd_secret, which detects resizes specifically (setting the size for > > the first time works just fine, since there are no existing pages to try > > to zero), and rejects them as not supported (ENOTSUP). > > Isn't ENOTTY the normal return value for this? Or even ENOSYS? I'm unsure. Since errno(3) says ENOTTY means "Inappropriate I/O control operation" that makes me think it's meant to be used only for ioctls? I tried ENOSYS, but checkpatch warns me it's meant to be used for "invalid syscall nr" and nothing else. ENOTSUP / ENOTSUPP / EOPNOTSUPP all have their own share of weirdnesses too, though. There's the whole ENOTSUP / ENOTSUPP mess, and then also the fact that glibc says ENOTSUP == EOPNOTSUPP, whereas POSIX says EOPNOTSUPP should be distinct and used specifically for sockets...