Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp151154ybg; Mon, 27 Jul 2020 18:40:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxc0ei3a4NWdkLvPshtaOvpNJIV7nj1WqTKKNahSZYxFTPuUt7IZvl4aNXIgnAKtr0gFmy2 X-Received: by 2002:a05:6402:13d0:: with SMTP id a16mr23712264edx.269.1595900443719; Mon, 27 Jul 2020 18:40:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595900443; cv=none; d=google.com; s=arc-20160816; b=fmh2gexYq8KDesiyI8oWZmGr49L/E75SIuqv9FhXCoYG66+4AYCImsV38AEWXUWmU5 3PH2ji43iS8M7a+KIy2DLxwnKuejEkkXwXDE/jdMFgR9HdyZ7Yl2Eo6X8J6XWyZbVQYA nTy5jds7FGekbt7Y6FQZdQx3xI2DXp7KnWGS2Tc2cWmhVxRoRIZ8rMAofD0kWr2mTvkY H8Uu6ZYvAhXSUhE7m2mUWO1THcmCyUaSaEwRzuZGM+pmE8wVUox24QZLkEXeLD1LscK9 Na+qKtHRaPEZ8l0BRr87ZzQtE9eAJO3cimStGYjPknHhQRpNrbyfoMp7LvZtVuW38cYY Cdzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=rwOY8YxgZ5QpwLDyDAZDf7H1P9wljCLWGMd+2npKJBM=; b=DFqWkzH4GR+6+P7XY3lxw775umwJROVU2B1jIW4DytS0+/6D5zBRwjcfd3R68Q5Uau EJgc+0gXcc2mlzwkPho02hdJ6F+pcl4Y6878LCEWG8zilPelo19yzyOiPkfGYJhXiP6h 96GXVUool3c7z/iqSZcxZBV0LR9dFIqjVqbBAc1ZEJSef35WyqOvaNc9aWHiOneaTmMR Ufzcgx4plH07tk0nb/VMYtUR23TY5H/a0coGaaAjMqK6i8eAx1nPhPKDI5ILeWGT0isz KYgv11RD3QJNdYAlyt7es8BjPNYOLjjsKdtd65Wxg65VTFeQj0Fhj+3GMb2V8PSECOso Ezmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tfz-net.20150623.gappssmtp.com header.s=20150623 header.b=MOlNb8No; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w9si6564254edr.171.2020.07.27.18.40.20; Mon, 27 Jul 2020 18:40:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@tfz-net.20150623.gappssmtp.com header.s=20150623 header.b=MOlNb8No; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726753AbgG1Bjv (ORCPT + 99 others); Mon, 27 Jul 2020 21:39:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726196AbgG1Bju (ORCPT ); Mon, 27 Jul 2020 21:39:50 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69AD2C061794 for ; Mon, 27 Jul 2020 18:39:50 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id o8so15756607wmh.4 for ; Mon, 27 Jul 2020 18:39:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tfz-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rwOY8YxgZ5QpwLDyDAZDf7H1P9wljCLWGMd+2npKJBM=; b=MOlNb8NoPIUUfR8CTs/ijaub4q4xeQjXKnkBHNwAa14H1Dd6e/nDvqfYG9o76lQVTE eAN0QcUHn/mXk3a71B+PWIt9/gyiGSnOU1mN2wYJE6kh+h2qjacUezbquyuNrABVzXGr 2QLQ7KWLtjy25fICkWKA7l0pBVUCODm17o5Vp3lYiGfMzJqqNzf0DG14wxBfstEAmW4w ef45SGrtTuk/3ZQVdOje7MzvLNAcbx6trAY/fDCNNSL1jPk3GLbPjvMLt0+ZrMnVCHax IcGaQ9njibv6jtOsowO4CK5auxqop1215tyGOOckvqNwdSmb+hRtJlhMbNxuLczCHj0L K4fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rwOY8YxgZ5QpwLDyDAZDf7H1P9wljCLWGMd+2npKJBM=; b=ubwGG5+q0BMnwI1oqYBCn5N4Oj4kzsb80tcUR8eGqdbMPACogHWQFWFkFFvBcxq4Rb UUZADvZsEurh+/QDXscblip4tgo1kEaBfr8XMWQWY1+6BM+VUYqSba+quQdDa1jwOzYf R4bS5PLiSpBv3FUQxo7D6Ntik9tb6mYdWcCfOS02aeY8ZLM9/0Kc13jgUS0AhdiMLDkK BqfJA+2GxGcn4fYlbKxXDyaoYwyz38zVNSxAjHu2DH1Vv09FR/BTK79pU1Ew085ohn6l yWcngkh581nVAk6rUZkFBKGEXNO/scYlhnD72az7ZXhWoVjnnIUC+DZWuPq2lCZ1jKgP YkLw== X-Gm-Message-State: AOAM530t9hQwGkI12Zb/wC9JAbT+qAXvBw/BLc4k+NtX0PvwMy2b8QpO fjc4ujGv2PvKHGeBt7jq4ByjrUPUrQW8jWcaoKU3+Q== X-Received: by 2002:a7b:cd0d:: with SMTP id f13mr1606237wmj.40.1595900389021; Mon, 27 Jul 2020 18:39:49 -0700 (PDT) MIME-Version: 1.0 References: <20200725045921.2723-1-kalou@tfz.net> <20200725052236.4062-1-kalou@tfz.net> <20200727142140.GA116567@localhost.localdomain> In-Reply-To: <20200727142140.GA116567@localhost.localdomain> From: Pascal Bouchareine Date: Mon, 27 Jul 2020 18:39:38 -0700 Message-ID: Subject: Re: [PATCH v3] proc,fcntl: introduce F_SET_DESCRIPTION To: Alexey Dobriyan Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, Al Viro , Jeff Layton , "J. Bruce Fields" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for reviewing, I added some questions inline below On Mon, Jul 27, 2020 at 7:21 AM Alexey Dobriyan wrote: > > + d = strndup_user(desc, MAX_FILE_DESC_SIZE); > > This should be kmem accounted because allocation is persistent. > To make things more entertaining, strndup_user() doesn't have gfp_t argument. I had to look it up so I might be very far from it, but is that __GFP_ACCOUNT and would it be correct to assume memdup_user() should use it unconditionally? Otherwise my simple option would be to implement the logic in the set_description, but the benefit would be very local. Please let me know what you think is best, happy to read more doc if there's a more productive way to address that > > > + if (IS_ERR(d)) > > + return PTR_ERR(d); > > + > > + spin_lock(&file->f_lock); > > + kfree(file->f_description); > > + file->f_description = d; > > + spin_unlock(&file->f_lock); > > Generally kfree under spinlock is not good idea. > You can replace the pointer and free without spinlock. Sorry I also need some pointers here - do you suggest I move the kfree out of the locked section or that there is a safe way other than spinlock? > struct file is nicely aligned to 256 bytes on distro configs. > Will this break everything? > > $ cat /sys/kernel/slab/filp/object_size Indeed on the config I'm using here this jumped to 264 bytes Would it be better to move this to the inode struct? I don't know the implications of this - any other option? Thanks!