Received: by 2002:ab2:2441:0:b0:1f3:1f8c:d0c6 with SMTP id k1csp36521lqe; Wed, 3 Apr 2024 21:06:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWupHpst+o0x6sG0lZbHi6QkUVEERkiCxO8a+BFoq0S8o3BelD7XKAsZ+TD2m7IY1hukdZKYuzorrHb4g/waY0YHK9T6/wQ1KFetAi9Kg== X-Google-Smtp-Source: AGHT+IGJr5ulZHEVFl17S/RvjpWN3z+tTYlFdMuEQYe/TEwebbwUTDNK4NLORM8Ma9wz9fLn1ns3 X-Received: by 2002:a05:6808:10d6:b0:3c2:2cf8:b8d with SMTP id s22-20020a05680810d600b003c22cf80b8dmr1590021ois.55.1712203586953; Wed, 03 Apr 2024 21:06:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712203586; cv=pass; d=google.com; s=arc-20160816; b=k2b0IVLETZ/bdRhG8qvAPI5B4joN6fukn+VkilYRGZHhHe4xmtKd/6mtQ3Ig/A4Kdo Gdvmn2NCgOC39cHmGYa8rwDMqMWF2LfLbRIAIoo7OalNeJ3sMIwsmUUnQE4Brf8fAm2d g1X2PFP9d2YRi6n7YXD753KOCgFh15DZ6QhNPF9V6n89V3TWS+7ir1Zt1e5ayNviDt1s fD6mwmQI7RsSX0gw1/wFaTt5pjfLBBGngbphsMnwD9WGdP5DNEmeKUm/3VL71/2NAi90 kXto/keLL2BM2Y5YjFDE7CE0CpbASSGjDjbT52sVL/bWeMyW778vc8uahiBzBJehSsZJ ahfA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=CbWk5huEObmhcA5g7RS6q+JrWme5Jfa+v58vnxeLScA=; fh=oA3V8ARPOSpr84T+i6QYtNgpLHOc/8pugSGyO/YUNHo=; b=AitJxJT1pZCkm774qNlLaCdhdsvsXePrarl5ZBBksJccTL/f//7ex3YRagczj9raWe MtXPEGxxJqgAcahXEXSdErRz1Qss7F6QopJj1znvikPvUA/A82vGKw7Zko9JmWoEL3Hi NdBcmkCBNL+qvb7NKEQ0YOeoXlqlSJWJiKDArjQ8WlFHUTPoLiscyZefJNAPTrUIQQQx zl/9H4GBa8BGHaj43olr3Lu1xOHNW5IZDjrc52mm1sduee92xZccM5RI3YNN/Cilb4AL hb/QdouqqHiLwyDp2tbhxeLhMZOOD2K3PJEKtBUPdSrQLvjJNMtBptsEasM9ygxC6/0/ bDiw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=o2SyvooU; arc=pass (i=1 dkim=pass dkdomain=linux.org.uk dmarc=pass fromdomain=zeniv.linux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-130704-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130704-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id c14-20020a631c4e000000b005d29ed61d61si13958986pgm.78.2024.04.03.21.06.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 21:06:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130704-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=o2SyvooU; arc=pass (i=1 dkim=pass dkdomain=linux.org.uk dmarc=pass fromdomain=zeniv.linux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-130704-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130704-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 95D85B2690D for ; Wed, 3 Apr 2024 22:58:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 394BE156C66; Wed, 3 Apr 2024 22:57:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="o2SyvooU" Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40A28156871; Wed, 3 Apr 2024 22:57:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712185071; cv=none; b=D1oZ5F7EBsmV92BZd0BhnyjTByv9vybYysQLyWjZnbaodKoDuvieeWCptqFHYxCdlno7jBPaoMJhEbeCTQ6LwDFhorU51QQ/U/ROffdq/XRFrSryhser5NpojtDXeLNMKqhctWvnSQq4vK8FeATSqtxEnKtcSrjZLDhEuXPPmbM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712185071; c=relaxed/simple; bh=GdJ01PLvlUXO2n1nMDCRGXdWiRPjGHJisvsRdsLX798=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ulcx3BhCfKhNOf5yieYQ8sek/DToN2X7tCZVNd1NxGYuAv4TCFmnxUN1bAvAeR7IRvQhceH1SyOv0NxUm6kIB026IavRdu4WfaDOi2Vj7CkFLAxKXGxwQWpYVCVsdjD+bykl1c1QMFd6YiVFA8Xps7bm9/Xmcj+acsWkxiA82w0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=o2SyvooU; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=CbWk5huEObmhcA5g7RS6q+JrWme5Jfa+v58vnxeLScA=; b=o2SyvooUZ3RyKcf/A0OloFojZu jTEW+zYs/9y+bXLfkWyE0ezuyrexew06OqIWb0wvmInMbTEsN84Lu8Gk6hQzJ95XaCcOgoJVvhEUX wluc/kCDcy8r6RRX3iKsi+1EfyvOi6VikZZlkfrgOu9Uky+bAZ8TjVB8cLWpmbp2D3OPMaxhesglM jxVSkV/9m1GR/D6UZJmp2CbdirwKrPdg16n2SyzmGlchvsilJ6ZYBeyeN4HaUuUIIcgUitqsl5y0r NHbv2dWHdv+o5IvdxGYay9wPBcIyeqt/7jSbdXKuIPWTgXxYNyRcMi8rN74+Oey+8fs9cFU/gPg/U mi79J3XQ==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1rs9YB-005ByQ-0W; Wed, 03 Apr 2024 22:57:47 +0000 Date: Wed, 3 Apr 2024 23:57:47 +0100 From: Al Viro To: Jens Axboe Cc: linux-fsdevel@vger.kernel.org, brauner@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] signalfd: convert to ->read_iter() Message-ID: <20240403225747.GO538574@ZenIV> References: <20240403140446.1623931-1-axboe@kernel.dk> <20240403140446.1623931-4-axboe@kernel.dk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240403140446.1623931-4-axboe@kernel.dk> Sender: Al Viro On Wed, Apr 03, 2024 at 08:02:54AM -0600, Jens Axboe wrote: > Rather than use the older style ->read() hook, use ->read_iter() so that > signalfd can support both O_NONBLOCK and IOCB_NOWAIT for non-blocking > read attempts. > > Split the fd setup into two parts, so that signalfd can mark the file > mode with FMODE_NOWAIT before installing it into the process table. Same issue with copy_to_iter() calling conventions; what's more, userland really does not expect partial copies here, so it might be worth adding static inline bool copy_to_iter_full(void *addr, size_t bytes, struct iov_iter *i) { size_t copied = copy_to_iter(addr, bytes, i); if (likely(copied == bytes)) return true; iov_iter_revert(i, copied); return false; } to include/linux/uio.h for the sake of those suckers. Then they could go for return copy_to_iter_full(&new, sizeof(new), to) ? sizeof(new) : -EFAULT; and similar in other two. NOTE: the userland ABI is somewhat sucky here - if the buffer goes unmapped (or r/o) at the offset that is *not* a multiple of sizeof(struct signalfd_siginfo), you get an event quietly lost. Not sure what can be done with that - it is a user-visible ABI.