From patchwork Mon Oct 17 19:20:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mirzamohammadi X-Patchwork-Id: 3668 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1605685wrs; Mon, 17 Oct 2022 12:21:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6911feYadL5HlGc9uOwA0LkI+EoWigc0iaiJdZ8bAZ/Txh3GO5ezWPtYlBJl1SNRVxf8GF X-Received: by 2002:a17:902:b78c:b0:17a:ec9:51da with SMTP id e12-20020a170902b78c00b0017a0ec951damr13446506pls.159.1666034502898; Mon, 17 Oct 2022 12:21:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666034502; cv=none; d=google.com; s=arc-20160816; b=IE+dUXvrTsOtsiwWjhEWQAs25ROpvNJ4RAT8XoohnBrWK5FTSwgbKa/wT/id0cJmkT eeM1WuztSPCKecj8hCxf0yZ0gE9+7NcJVW/bv61XlNgbF0K3KNZV/wQPPlqyUxk0GKsS 3iJOiLCGL8thVl+AcaHBOwzbXt7glKbSjPhAaLYxpexHiWLSOc4eM28vIprYIQpwysuM Wi7/HtqWBgVim5UINcwUZ1dQ+NOYBzcKlayu6ZiwEGOcKBVpilin5DvMfjJ9cV4x7T2Z NKp8pOQC/zw/jRrTHy0K4nmAFkthK0aWolwrjpofLipGYHm/+dFYmETRjqx3ljVycsZ5 Hq0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=brPOhumrB5oqQEjai/DMj1NxCaV7hOCcgnerJu2uuBk=; b=FCp3Utehj5J9zX8QEj8xnvA+knc8hy2LBp9/LbXJNXcYRNeQimdFyfoCuKoZamJkZf xWh+jPdSe6PZ1zgAEp+qXzJntjYisDiUtW/GmXkct9Vtt/z9+X8KLvDLPptnw81b4FbD 2GEHL+DNzoeGSS+YAGQbR63Nvjgj+5mIFaRAW7AmLixqcj4xXgjTgQ0VwNsbEJwim2DI yrFENu3zztGBdN1OCzw+t8J3ShfV5wj7H4QHE39wbhke+F0stDdYQZuqdrN5czJWtSxS iEHcOQPJfM5tzYwg7jDY4ytzYaxDImqqwEgB8yo5s9wXE4yovDFchKklRslpYMCpXKjY 8DbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@oracle.com header.s=corp-2022-7-12 header.b="Qyss/Uod"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x9-20020a63cc09000000b004580a3b847dsi11981056pgf.287.2022.10.17.12.21.29; Mon, 17 Oct 2022 12:21:42 -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=fail header.i=@oracle.com header.s=corp-2022-7-12 header.b="Qyss/Uod"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230504AbiJQTU5 (ORCPT + 99 others); Mon, 17 Oct 2022 15:20:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230413AbiJQTUi (ORCPT ); Mon, 17 Oct 2022 15:20:38 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AF17FD30; Mon, 17 Oct 2022 12:20:32 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29HITJ6I005795; Mon, 17 Oct 2022 19:20:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2022-7-12; bh=brPOhumrB5oqQEjai/DMj1NxCaV7hOCcgnerJu2uuBk=; b=Qyss/UodxvPvQTFWD6M36tPec/2nD1vA2vSGF8UmJ9G4TqvkhjiR/7jzD+9uandTHAfn PFQExAALGi3F6TrubN00FJ9++D28QkeOZXo6wwtgoGt5N11U4WPzmr4XmWLp++zBCQ/e JGnrxYIIDMNz1Hq69cVYc7y8HqgkPmJ3/UMVOCtMcvr6qb3d5qfNayQxNTtX75oAiTzA ORHrpTMDRpwzdblgnIByb3goxYlwK7t99EXTQf8XdbRLEoTwhQ0sPiorF2QYGkDpAunV mOVdieoyc3OtYvoM+t7ONi+XvyFzmoeHBB4zuSGvTG2yGkIVq1D+BMw0GoVZ979BlBYY 2g== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k7mw3cgfa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 19:20:31 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 29HHfDeq036341; Mon, 17 Oct 2022 19:20:30 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3k8htf4as4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 19:20:30 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29HJKCYp007860; Mon, 17 Oct 2022 19:20:29 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.147.25.63]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3k8htf4abs-2; Mon, 17 Oct 2022 19:20:29 +0000 From: Saeed Mirzamohammadi Cc: linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, stable@vger.kernel.org, jason@zx2c4.com, saeed.mirzamohammadi@oracle.com, "Jason A. Donenfeld" Subject: [PATCH stable 1/5] fs: clear or set FMODE_LSEEK based on llseek function Date: Mon, 17 Oct 2022 12:20:02 -0700 Message-Id: <20221017192006.36398-2-saeed.mirzamohammadi@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221017192006.36398-1-saeed.mirzamohammadi@oracle.com> References: <20221017192006.36398-1-saeed.mirzamohammadi@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-17_13,2022-10-17_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 mlxscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210170111 X-Proofpoint-ORIG-GUID: k3TBF23zYJuaYDMzLR_utHkoDKLSDgOc X-Proofpoint-GUID: k3TBF23zYJuaYDMzLR_utHkoDKLSDgOc X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) 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?1746963794676152808?= X-GMAIL-MSGID: =?utf-8?q?1746963794676152808?= From: "Jason A. Donenfeld" Pipe-like behaviour on llseek(2) (i.e. unconditionally failing with -ESPIPE) can be expresses in 3 ways: 1) ->llseek set to NULL in file_operations 2) ->llseek set to no_llseek in file_operations 3) FMODE_LSEEK *not* set in ->f_mode. Enforce (3) in cases (1) and (2); that will allow to simplify the checks and eventually get rid of no_llseek boilerplate. Signed-off-by: Jason A. Donenfeld Signed-off-by: Al Viro (cherry picked from commit e7478158e1378325907edfdd960eca98a1be405b) Conflicts: fs/open.c Cc: stable@vger.kernel.org Signed-off-by: Saeed Mirzamohammadi --- fs/file_table.c | 2 ++ fs/open.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/fs/file_table.c b/fs/file_table.c index e8c9016703ad..f675817be4ad 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -198,6 +198,8 @@ static struct file *alloc_file(const struct path *path, int flags, file->f_mapping = path->dentry->d_inode->i_mapping; file->f_wb_err = filemap_sample_wb_err(file->f_mapping); file->f_sb_err = file_sample_sb_err(file); + if (fop->llseek && fop->llseek != no_llseek) + file->f_mode |= FMODE_LSEEK; if ((file->f_mode & FMODE_READ) && likely(fop->read || fop->read_iter)) file->f_mode |= FMODE_CAN_READ; diff --git a/fs/open.c b/fs/open.c index 1ba1d2ab2ef0..38bf38d41418 100644 --- a/fs/open.c +++ b/fs/open.c @@ -834,6 +834,10 @@ static int do_dentry_open(struct file *f, if ((f->f_mode & FMODE_WRITE) && likely(f->f_op->write || f->f_op->write_iter)) f->f_mode |= FMODE_CAN_WRITE; + if ((f->f_mode & FMODE_LSEEK) && !f->f_op->llseek) + f->f_mode &= ~FMODE_LSEEK; + if ((f->f_mode & FMODE_LSEEK) && f->f_op->llseek == no_llseek) + f->f_mode &= ~FMODE_LSEEK; f->f_write_hint = WRITE_LIFE_NOT_SET; f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); From patchwork Mon Oct 17 19:20:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mirzamohammadi X-Patchwork-Id: 3666 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1605551wrs; Mon, 17 Oct 2022 12:21:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4571KWTT/OGUMshdaZTO4AhtofCtH1G3WSIZK0KcLVq9Oh5WN9bXaFxjW7rlYCM+kiqz6R X-Received: by 2002:a63:ff4f:0:b0:439:61d6:197 with SMTP id s15-20020a63ff4f000000b0043961d60197mr11825211pgk.67.1666034481995; Mon, 17 Oct 2022 12:21:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666034481; cv=none; d=google.com; s=arc-20160816; b=JReIUYnd+j0fIUIo6UzXPt29mZyYjcjdPaZW8rwGMG4XtHsV5Nk9ovVivcGhISy8v0 UOIp2ynjIFB5GMm+cOlYOTv2XeEophjqUHoI0wlTh2xpKu8ebC6CtoiC/yqIBSZ/57Zt qPmIiXbzsa0etUmnQil2MXtfdx4hMpwctL6KF+SGfncTXscd0VFRrLbOywvAinlgLi2o ed7Jx1Sh9dXz1+HSKzXqjbhJMWuxGXw5g/+7O8N+AiIQfSXM5WusluWYfQ/LT29US96B 4o8XN3k9W+6Hk2qO+ws5sDf5V5Qe8BSvzNG13lgLFGu/Xf4/eyYxs99FevOf2600pG4j K90A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=3l6Jm/j5UGLMxQsiYqUPn8xoi5WXHOYfNbpCDtSFPMI=; b=iOSc/Iq0Rf64hHVEAF30gmPqFPfiTK/6KxT8HG5rMRwyOv2Pe8VM8fUM7jUnv57Gsi chEd4pMBBVMMMng63Vu7Q3mBaPdd/NCSW7h5N6dmWkx0iwPdizYAzRQqJCVAcoGZDkJE 8LbKw72omhsDP5qHtgU4sg8PAiRFP3AWSv3hsQfcwNkGRs+6HvTPDv7/4z2auSGsnMqg joMm3duxM3Tk+zJ5zSsImwPEgAAaX+XbewX55uL2YSP+ZwejGyVMwHfPqS8v3f0UWiuO ZQ2XlfRp5Yl9VzsexibDR5r9Ci0hqnCFp7xSKgnBraLEuzNyvdIcp9/DMWaPQfKEETZX 51pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@oracle.com header.s=corp-2022-7-12 header.b=1zMdrNYk; 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=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a056a000a8800b0053e2be48c98si13218859pfl.76.2022.10.17.12.21.08; Mon, 17 Oct 2022 12:21:21 -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=fail header.i=@oracle.com header.s=corp-2022-7-12 header.b=1zMdrNYk; 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=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230209AbiJQTUs (ORCPT + 99 others); Mon, 17 Oct 2022 15:20:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230431AbiJQTUj (ORCPT ); Mon, 17 Oct 2022 15:20:39 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 861277674E; Mon, 17 Oct 2022 12:20:36 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29HITJ4J026745; Mon, 17 Oct 2022 19:20:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2022-7-12; bh=3l6Jm/j5UGLMxQsiYqUPn8xoi5WXHOYfNbpCDtSFPMI=; b=1zMdrNYksEDo7ORUz3SeEO3Z/w5pDWTSJUGZ3Qk2m93r7yNI7Ff6x3axRI7Ry9KSb3CP Z+YipYNuUS7cbBQWYxvc96JysTYQNV6hbtxhMh50ZjEtRi44lV+JVilbtBUkpjBpTshO RPGjkDaWJsm7kGPTsDA0fvsoNAK5NkrX2x3IxlceFkN1LVo/AiLPD56gUYd6y9sEzBjh q0/hFJh1I+6XtaL1TzXkL1hn2KqQQJay2O7vXLECGPhhS1FFpCEsntbEDIZNAk7VOL5p nthtmutVzAbVDZA/tyPCK6xauW24q23UAgZiNeuFGeySS+ONHtTCpqurU0huTeQ0QHP6 Cw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k9b7sga5a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 19:20:35 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 29HHae95036317; Mon, 17 Oct 2022 19:20:34 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3k8htf4avv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 19:20:34 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29HJKCYr007860; Mon, 17 Oct 2022 19:20:34 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.147.25.63]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3k8htf4abs-3; Mon, 17 Oct 2022 19:20:33 +0000 From: Saeed Mirzamohammadi Cc: linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, stable@vger.kernel.org, jason@zx2c4.com, saeed.mirzamohammadi@oracle.com, "Jason A. Donenfeld" Subject: [PATCH stable 2/5] fs: do not compare against ->llseek Date: Mon, 17 Oct 2022 12:20:03 -0700 Message-Id: <20221017192006.36398-3-saeed.mirzamohammadi@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221017192006.36398-1-saeed.mirzamohammadi@oracle.com> References: <20221017192006.36398-1-saeed.mirzamohammadi@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-17_13,2022-10-17_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 mlxscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210170111 X-Proofpoint-GUID: MHRi98lwiCqt0TgbuOmYkPTCCLszGlZv X-Proofpoint-ORIG-GUID: MHRi98lwiCqt0TgbuOmYkPTCCLszGlZv X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) 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?1746963772687104765?= X-GMAIL-MSGID: =?utf-8?q?1746963772687104765?= From: "Jason A. Donenfeld" Now vfs_llseek() can simply check for FMODE_LSEEK; if it's set, we know that ->llseek() won't be NULL and if it's not we should just fail with -ESPIPE. A couple of other places where we used to check for special values of ->llseek() (somewhat inconsistently) switched to checking FMODE_LSEEK. Signed-off-by: Jason A. Donenfeld Signed-off-by: Al Viro (cherry picked from commit 4e3299eaddffd9d7d5b8bae28ad700bb775f02d0) Cc: stable@vger.kernel.org Signed-off-by: Saeed Mirzamohammadi --- fs/coredump.c | 4 ++-- fs/overlayfs/copy_up.c | 3 +-- fs/read_write.c | 11 +++-------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/fs/coredump.c b/fs/coredump.c index 26eb5a095832..04ce02e30e23 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -886,9 +886,9 @@ static int __dump_skip(struct coredump_params *cprm, size_t nr) { static char zeroes[PAGE_SIZE]; struct file *file = cprm->file; - if (file->f_op->llseek && file->f_op->llseek != no_llseek) { + if (file->f_mode & FMODE_LSEEK) { if (dump_interrupted() || - file->f_op->llseek(file, nr, SEEK_CUR) < 0) + vfs_llseek(file, nr, SEEK_CUR) < 0) return 0; cprm->pos += nr; return 1; diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index e040970408d4..7636ec4d8b1c 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -226,8 +226,7 @@ static int ovl_copy_up_data(struct ovl_fs *ofs, struct path *old, /* Couldn't clone, so now we try to copy the data */ /* Check if lower fs supports seek operation */ - if (old_file->f_mode & FMODE_LSEEK && - old_file->f_op->llseek) + if (old_file->f_mode & FMODE_LSEEK) skip_hole = true; while (len) { diff --git a/fs/read_write.c b/fs/read_write.c index 8d3ec975514d..b64527211b32 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -290,14 +290,9 @@ EXPORT_SYMBOL(default_llseek); loff_t vfs_llseek(struct file *file, loff_t offset, int whence) { - loff_t (*fn)(struct file *, loff_t, int); - - fn = no_llseek; - if (file->f_mode & FMODE_LSEEK) { - if (file->f_op->llseek) - fn = file->f_op->llseek; - } - return fn(file, offset, whence); + if (!(file->f_mode & FMODE_LSEEK)) + return -ESPIPE; + return file->f_op->llseek(file, offset, whence); } EXPORT_SYMBOL(vfs_llseek); From patchwork Mon Oct 17 19:20:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mirzamohammadi X-Patchwork-Id: 3670 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1605757wrs; Mon, 17 Oct 2022 12:21:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7fsfTjBfH77FhHr+jFvxCBaM83emvGsple3185F+DtRmrIJZfqmaok2IyuqoC5GoqVTQs9 X-Received: by 2002:a17:90b:1a8d:b0:20d:be0b:a320 with SMTP id ng13-20020a17090b1a8d00b0020dbe0ba320mr20713467pjb.107.1666034514365; Mon, 17 Oct 2022 12:21:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666034514; cv=none; d=google.com; s=arc-20160816; b=gRqef2oL/WXKqqJiBEcvRpG5mEObicWx6QL2LAMD/CGMK4tCDe2zkn4+DShR/YNvjw Bu4e77/p4Z5Tf9EubUq5UEktwBMk5b6tfN9JlHjhyXjJx93ebZXr6pfTLB6rQVWOHQ1G Xcm9IN6p9kmJGRsvBKGs+KId9yeL3c+T1SbcykR4mjJ1GoQvXQ2Vhc8OgSuN392GPpFK wS+4wpZoGG+QUXF8XRcGtyOe3vGjv+NyFuw9NgAsD6lCaOGdAKHz7EOUewWWpNbAUAVZ wlJjhzIIcN5bbkmATBo4krXGROFSvPqxVNdUcd7R+D9CRsgeJgja8aUpeiNC4JHHn5Lq DD2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=lsHbolG0UmSy55V8F7V+ni/Cjto00pDK8F+j9k18zVo=; b=ne5O7aV2U/mqkQJJLWngFlLouf78pxa27Mb19YVT9vwBIJZTv11qhNnOELt3Aos3d8 nYtx3kYgZnFsshj7oKdGJwmm8Esl+odYyDedSZ5tbRtS4PuOhP97PACvxTko+ub2Q58G evNo8KMVPGYuy1gNc4olHQpIlpgCB/EMo1blfZlDOhPABskvb/vMBcUQq1e5cP79qUwN LIurhvHonZBdPHGIQ6yj3H58SU14aXUZ/Q0wohsaRk1OnCZWCrRWGT5l5Ian9PDhsyYp 9FG0rM7GEW8YyWleTWiQRYv+A35jtMab7nX2lHTi8VSvxUNuK0955qsiiw2yZCJSM3J2 jBFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@oracle.com header.s=corp-2022-7-12 header.b=giOy2bBj; 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=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k4-20020a170902ce0400b001786f5de8f2si13897905plg.95.2022.10.17.12.21.41; Mon, 17 Oct 2022 12:21:54 -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=fail header.i=@oracle.com header.s=corp-2022-7-12 header.b=giOy2bBj; 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=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231206AbiJQTVP (ORCPT + 99 others); Mon, 17 Oct 2022 15:21:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230339AbiJQTUn (ORCPT ); Mon, 17 Oct 2022 15:20:43 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CAC076765; Mon, 17 Oct 2022 12:20:39 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29HITLld026790; Mon, 17 Oct 2022 19:20:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2022-7-12; bh=lsHbolG0UmSy55V8F7V+ni/Cjto00pDK8F+j9k18zVo=; b=giOy2bBj1mWTtkcC2aWQQyGfv6ikhSOxglqWMlnplrj35A3NkEgly7tYgMTKO3FMfUJL tDU0/yVU9EMT/rlRJdpEXo2uuIwqDAgT7wsftlMFITdHCmsDQGWpOkumoFfYbF0JVWSK ThLsfV6ZZgX0hqKfkjGZIakjhdzuHGrHke+4PeKXc61b5pk708XkpQfXKpdkYVn/JoAl tL6ixJKcnhde/0PkrkZjqTAeZSgx3G1nRHZAx+ydDeVQVn+V/w/8DL8JzWq2op9NXqrQ kwk+Y4WrM6AfqOlykYeboa+lPB9kEMBu+4xhlkQ83CXrpvKH10S1bjKb5XBSCnMGcfBe cA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k9b7sga5d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 19:20:37 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 29HHaCIQ036466; Mon, 17 Oct 2022 19:20:36 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3k8htf4axt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 19:20:36 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29HJKCYt007860; Mon, 17 Oct 2022 19:20:36 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.147.25.63]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3k8htf4abs-4; Mon, 17 Oct 2022 19:20:36 +0000 From: Saeed Mirzamohammadi Cc: linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, stable@vger.kernel.org, jason@zx2c4.com, saeed.mirzamohammadi@oracle.com, "Jason A. Donenfeld" , Daniel Vetter , Sumit Semwal Subject: [PATCH stable 3/5] dma-buf: remove useless FMODE_LSEEK flag Date: Mon, 17 Oct 2022 12:20:04 -0700 Message-Id: <20221017192006.36398-4-saeed.mirzamohammadi@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221017192006.36398-1-saeed.mirzamohammadi@oracle.com> References: <20221017192006.36398-1-saeed.mirzamohammadi@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-17_13,2022-10-17_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 mlxscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210170111 X-Proofpoint-GUID: IfQwHx-IBwVlW4UHk92EIGqK_UGIMkmr X-Proofpoint-ORIG-GUID: IfQwHx-IBwVlW4UHk92EIGqK_UGIMkmr X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) 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?1746963806654795731?= X-GMAIL-MSGID: =?utf-8?q?1746963806654795731?= From: "Jason A. Donenfeld" This is already set by anon_inode_getfile(), since dma_buf_fops has non-NULL ->llseek, so we don't need to set it here too. Acked-by: Daniel Vetter Acked-by: Sumit Semwal Signed-off-by: Jason A. Donenfeld Signed-off-by: Al Viro (cherry picked from commit c9eb2d427c1c428e4f4e29f1e635b9a83236c015) Cc: stable@vger.kernel.org Signed-off-by: Saeed Mirzamohammadi --- drivers/dma-buf/dma-buf.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 968c3df2810e..3c3d0e2258b4 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -584,7 +584,6 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info) goto err_dmabuf; } - file->f_mode |= FMODE_LSEEK; dmabuf->file = file; mutex_init(&dmabuf->lock); From patchwork Mon Oct 17 19:20:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mirzamohammadi X-Patchwork-Id: 3676 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1606004wrs; Mon, 17 Oct 2022 12:22:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM48Vh/DLG5M6FNpwekl+PNlABip3a8Pi+yVh9D5KF711FVhp8XP2WXffbGJduQVVKX/rjzs X-Received: by 2002:a17:90b:3912:b0:20d:4151:1b65 with SMTP id ob18-20020a17090b391200b0020d41511b65mr35405643pjb.233.1666034551317; Mon, 17 Oct 2022 12:22:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666034551; cv=none; d=google.com; s=arc-20160816; b=p55e8JaMHnp3yxRLkM1gXJLf2EykuVfABjpZmDZEbRABVRaNQJ6ir2gZAbnLw8zk2+ awqv3Rb28tzuQ4zj8rG0LM/x0aiZmHQzo0vHGiUUKRFRjdm2licUdYXM5bpG018Dsaqz 8nBVy0mXhRAwGMOO6y5P3/mjRA9FGTrr+af97jxldkPW2h38Zm/p+23guN8TWF4edBGd 4MfS9nSZcLm+60mo9VwTvR/s0lc3Xc2KpGs8XZj5yKPuTSpW294iEe5dvB51tK6XA//g GesI21Im+Y+Sm+fevqGuKUJ6yEjWBnPcuHryUoEVT85DiVYCa+TFAvR1dlngEp5h5OUH nnug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=MCMejsWJItNd+KolSCgm5ldOdyDz/Mq994rgjl062DQ=; b=mr/Xrz92/siCXNqm9MpjUSLEdLHG6k0a2vWdavVBro02xbQ7iM8b9ckHUdvgp/ON53 A5lx9wAZ+D7ZNl0AWcc+EQOD62yac37t0cX0FObBmq8V9GtH0AOm+uVLpIX/c4mz3Acc bBtq23cHO4zcwHHLSh7ompRUwEJjFX8NcN/rB0b+fBFwPZ2JGwJbVO2cVMy1C1bhXkz0 hr8Sk8xWPCx3uUFjouEyq04cj924MHs27+tnJrT5oxVYHeT+nKde+usiVKFaLY8KWBt4 6o68G3yfX7qIt/k7m6vMWtVB+cwzZjsYCBr/4D8S+aUTHqc5Z7OTxurZnXYvSBm4aYWM 7h1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@oracle.com header.s=corp-2022-7-12 header.b=mJaqFXIJ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a68-20020a636647000000b0045ce0eba520si12033219pgc.751.2022.10.17.12.22.19; Mon, 17 Oct 2022 12:22:31 -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=fail header.i=@oracle.com header.s=corp-2022-7-12 header.b=mJaqFXIJ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231165AbiJQTVH (ORCPT + 99 others); Mon, 17 Oct 2022 15:21:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230450AbiJQTUs (ORCPT ); Mon, 17 Oct 2022 15:20:48 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26F8D5C943; Mon, 17 Oct 2022 12:20:42 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29HITPOY022718; Mon, 17 Oct 2022 19:20:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2022-7-12; bh=MCMejsWJItNd+KolSCgm5ldOdyDz/Mq994rgjl062DQ=; b=mJaqFXIJGmhCUdCxtYWne6DZUJ5bom5SIds5qObVpogQefuoe9LS0X6a1ZwjhGDaK/u5 ky4h6xt8yalsvoSvvvGVCntURrRf1c21QFZx8o9SJrBEwIWGG4F0TvwIGGthn61MzQ6/ kWqNVcflDLFJv1QxX89sVIFDRqpurMDxS2vr94Jfdl6wDR9fibyudWm9MNnpoPrAF4gU NbNIX0JdejOF2mymfL1uWMLQOX8NtvInzPKMLNj1C6slRCZcp/JJabSJif2pYcLWfdfZ z3RPHmo1Bo02Z3qJjdwZSzsE5UzHCQsDXxyOJp2QQSxdbgFM968jjvxEkliyzgioPcIm rg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k7mtyvqvj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 19:20:39 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 29HHfDf0036341; Mon, 17 Oct 2022 19:20:39 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3k8htf4b0r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 19:20:39 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29HJKCYv007860; Mon, 17 Oct 2022 19:20:38 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.147.25.63]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3k8htf4abs-5; Mon, 17 Oct 2022 19:20:38 +0000 From: Saeed Mirzamohammadi Cc: linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, stable@vger.kernel.org, jason@zx2c4.com, saeed.mirzamohammadi@oracle.com, "Jason A. Donenfeld" , Alex Williamson Subject: [PATCH stable 4/5] vfio: do not set FMODE_LSEEK flag Date: Mon, 17 Oct 2022 12:20:05 -0700 Message-Id: <20221017192006.36398-5-saeed.mirzamohammadi@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221017192006.36398-1-saeed.mirzamohammadi@oracle.com> References: <20221017192006.36398-1-saeed.mirzamohammadi@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-17_13,2022-10-17_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 mlxscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210170111 X-Proofpoint-ORIG-GUID: c2l-luNZpKMZjPvCjlcpybMw--ZxWf9M X-Proofpoint-GUID: c2l-luNZpKMZjPvCjlcpybMw--ZxWf9M X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) 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?1746963845763396093?= X-GMAIL-MSGID: =?utf-8?q?1746963845763396093?= From: "Jason A. Donenfeld" This file does not support llseek, so don't set the flag advertising it. Acked-by: Alex Williamson Signed-off-by: Jason A. Donenfeld Signed-off-by: Al Viro (cherry picked from commit 54ef7a47f67de9e87022a5310d1e8332af3e2696) Cc: stable@vger.kernel.org Signed-off-by: Saeed Mirzamohammadi --- drivers/vfio/vfio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 818e47fc0896..93346a76aa7b 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -1490,7 +1490,7 @@ static int vfio_group_get_device_fd(struct vfio_group *group, char *buf) * Appears to be missing by lack of need rather than * explicitly prevented. Now there's need. */ - filep->f_mode |= (FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE); + filep->f_mode |= (FMODE_PREAD | FMODE_PWRITE); atomic_inc(&group->container_users); From patchwork Mon Oct 17 19:20:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mirzamohammadi X-Patchwork-Id: 3667 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1605602wrs; Mon, 17 Oct 2022 12:21:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7nHwSKp4UrmqTTFskbjisqLC0GqshgQi/lkQ2Ckn6PuQ6inYo1FmT/Lb1K5GJ6iA551bVD X-Received: by 2002:a17:902:be03:b0:17b:80c1:78c2 with SMTP id r3-20020a170902be0300b0017b80c178c2mr13479128pls.34.1666034492555; Mon, 17 Oct 2022 12:21:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666034492; cv=none; d=google.com; s=arc-20160816; b=jDRDxjTTge2/q2lsG0qiSFmc3cpSFXl9vSkTeJPj9MzqKKkGgMADOxSKpvk6iCUhQi 0HyffwkJsYuuJaK81AwZuuCnxAviZzcMynvWZziUuBo7dQqkBKNabwBD9dzb+HZYoyyG xr39LGNDB3acwMgk/BC3N7Ybltei19MQlLbLF5c2IFe+sT3wEKCgUCWA9bVlTGLDIdTQ ahbFNHxtNjIvhNWHnnAryGXdiE4Rb3tsSBYYZepYCSebpMAMV8PvkPHEgHCw98mH51Rg mWmLVvnY06+Be1CXKLLzViqsEW42n4O8+8P4fDjWGlWjPMnDiWHAWaGW7zJempmMuK50 o4Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=eNm2INiTaoShknyJ5OevDiDEJxGt8eereztJzFcRVwg=; b=LfxYfFC+kpxyxAc9f6LBjD9PW+Am88Hyn5/gV0kOEnE/qRiSnJHp4vNefgZxGEHknf /BsJV+VX2Fv2m/AUUm5DPGP5ypu6fcybmuwRlVKAVyXpilvvJkydfMCpda+TQqUzHXnU b3eylbsXKbWDDUU2OK19O40wStZ4HfEjpB1GsGvqMpyztbQX3yYVpHUO7A7Cknano7ul 2boScKsDXp89qh9WmD+7I/NEBQ5RBqp7qmRCJJXWXPapc7HTTpJpmAsm6azyo/0QGokC t/Emeu4gfozDSvisOeH2441fZ0owH7yI7dPzhXwQJxo/9MUZkGwac+HVF8Ym8OGrEjaP E+Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@oracle.com header.s=corp-2022-7-12 header.b=Vto6vkVz; 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=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a7-20020a637047000000b00434df8032e4si13092127pgn.139.2022.10.17.12.21.18; Mon, 17 Oct 2022 12:21:32 -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=fail header.i=@oracle.com header.s=corp-2022-7-12 header.b=Vto6vkVz; 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=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230346AbiJQTVC (ORCPT + 99 others); Mon, 17 Oct 2022 15:21:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230447AbiJQTUr (ORCPT ); Mon, 17 Oct 2022 15:20:47 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8763226120; Mon, 17 Oct 2022 12:20:43 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29HITP1R022722; Mon, 17 Oct 2022 19:20:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2022-7-12; bh=eNm2INiTaoShknyJ5OevDiDEJxGt8eereztJzFcRVwg=; b=Vto6vkVzTkpIvV1QahWukLv66Kk+KAlUAGTzC2eFCKRP+8rcuwHRbVFe1EVm8yi5LwF1 aElRg3PcWEwcEXlXUOQCxi6YmO7nMfAmFbqIOHZMLQnnATQfAxu2HtZTFzxygeABqgYm zS/dDgtLbR2z+xR1Ri7x28Ct1P09z19xpa7orxDckng8XkzQIY3atdyWjWtnRBKSpeAB Rte0yzrAM0WrgWeN4orDaNHVy/eaJ0MmaA+9D/HnwgxX14KhXc+vDR+bw61Vw2kO9dTi qjqYtV7i5leeCdU9jH7spbpl0+Ciw5yAizwi8Db9GHPA4AgsvwTo4a1tpuVUm2n4Sscp Vg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k7mtyvqvp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 19:20:41 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 29HIGwlT036362; Mon, 17 Oct 2022 19:20:41 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3k8htf4b26-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 19:20:41 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29HJKCYx007860; Mon, 17 Oct 2022 19:20:40 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.147.25.63]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3k8htf4abs-6; Mon, 17 Oct 2022 19:20:40 +0000 From: Saeed Mirzamohammadi Cc: linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, stable@vger.kernel.org, jason@zx2c4.com, saeed.mirzamohammadi@oracle.com, "Jason A. Donenfeld" Subject: [PATCH stable 5/5] fs: remove no_llseek Date: Mon, 17 Oct 2022 12:20:06 -0700 Message-Id: <20221017192006.36398-6-saeed.mirzamohammadi@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221017192006.36398-1-saeed.mirzamohammadi@oracle.com> References: <20221017192006.36398-1-saeed.mirzamohammadi@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-17_13,2022-10-17_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 mlxscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210170111 X-Proofpoint-ORIG-GUID: jh-JerGZq8d70Q-YXCdtol2dKiOuTSMY X-Proofpoint-GUID: jh-JerGZq8d70Q-YXCdtol2dKiOuTSMY X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) 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?1746963784024343251?= X-GMAIL-MSGID: =?utf-8?q?1746963784024343251?= From: "Jason A. Donenfeld" Now that all callers of ->llseek are going through vfs_llseek(), we don't gain anything by keeping no_llseek around. Nothing actually calls it and setting ->llseek to no_lseek is completely equivalent to leaving it NULL. Longer term (== by the end of merge window) we want to remove all such intializations. To simplify the merge window this commit does *not* touch initializers - it only defines no_llseek as NULL (and simplifies the tests on file opening). At -rc1 we'll need do a mechanical removal of no_llseek - git grep -l -w no_llseek | grep -v porting.rst | while read i; do sed -i '/\/d' $i done would do it. Signed-off-by: Jason A. Donenfeld Signed-off-by: Al Viro (cherry picked from commit 868941b14441282ba08761b770fc6cad69d5bdb7) Conflicts: fs/open.c Cc: stable@vger.kernel.org Signed-off-by: Saeed Mirzamohammadi --- Documentation/filesystems/porting.rst | 8 ++++++++ drivers/gpu/drm/drm_file.c | 3 +-- fs/file_table.c | 2 +- fs/read_write.c | 6 ------ include/linux/fs.h | 2 +- kernel/bpf/bpf_iter.c | 3 +-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesystems/porting.rst index bf19fd6b86e7..9d362f80a644 100644 --- a/Documentation/filesystems/porting.rst +++ b/Documentation/filesystems/porting.rst @@ -908,3 +908,11 @@ Calling conventions for file_open_root() changed; now it takes struct path * instead of passing mount and dentry separately. For callers that used to pass mnt_root> pair (i.e. the root of given mount), a new helper is provided - file_open_root_mnt(). In-tree users adjusted. + +--- + +**mandatory** + +no_llseek is gone; don't set .llseek to that - just leave it NULL instead. +Checks for "does that file have llseek(2), or should it fail with ESPIPE" +should be done by looking at FMODE_LSEEK in file->f_mode. diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index ed25168619fc..dc7d2e5b16c8 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -552,8 +552,7 @@ EXPORT_SYMBOL(drm_release_noglobal); * Since events are used by the KMS API for vblank and page flip completion this * means all modern display drivers must use it. * - * @offset is ignored, DRM events are read like a pipe. Therefore drivers also - * must set the &file_operation.llseek to no_llseek(). Polling support is + * @offset is ignored, DRM events are read like a pipe. Polling support is * provided by drm_poll(). * * This function will only ever read a full event. Therefore userspace must diff --git a/fs/file_table.c b/fs/file_table.c index f675817be4ad..652b70841df6 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -198,7 +198,7 @@ static struct file *alloc_file(const struct path *path, int flags, file->f_mapping = path->dentry->d_inode->i_mapping; file->f_wb_err = filemap_sample_wb_err(file->f_mapping); file->f_sb_err = file_sample_sb_err(file); - if (fop->llseek && fop->llseek != no_llseek) + if (fop->llseek) file->f_mode |= FMODE_LSEEK; if ((file->f_mode & FMODE_READ) && likely(fop->read || fop->read_iter)) diff --git a/fs/read_write.c b/fs/read_write.c index b64527211b32..582beb67e48e 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -227,12 +227,6 @@ loff_t noop_llseek(struct file *file, loff_t offset, int whence) } EXPORT_SYMBOL(noop_llseek); -loff_t no_llseek(struct file *file, loff_t offset, int whence) -{ - return -ESPIPE; -} -EXPORT_SYMBOL(no_llseek); - loff_t default_llseek(struct file *file, loff_t offset, int whence) { struct inode *inode = file_inode(file); diff --git a/include/linux/fs.h b/include/linux/fs.h index 76162f046670..f5eac9d76e9d 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3174,7 +3174,7 @@ extern long do_splice_direct(struct file *in, loff_t *ppos, struct file *out, extern void file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping); extern loff_t noop_llseek(struct file *file, loff_t offset, int whence); -extern loff_t no_llseek(struct file *file, loff_t offset, int whence); +#define no_llseek NULL extern loff_t vfs_setpos(struct file *file, loff_t offset, loff_t maxsize); extern loff_t generic_file_llseek(struct file *file, loff_t offset, int whence); extern loff_t generic_file_llseek_size(struct file *file, loff_t offset, diff --git a/kernel/bpf/bpf_iter.c b/kernel/bpf/bpf_iter.c index b2ee45064e06..60e8f611954e 100644 --- a/kernel/bpf/bpf_iter.c +++ b/kernel/bpf/bpf_iter.c @@ -80,10 +80,9 @@ static bool bpf_iter_support_resched(struct seq_file *seq) #define MAX_ITER_OBJECTS 1000000 /* bpf_seq_read, a customized and simpler version for bpf iterator. - * no_llseek is assumed for this file. * The following are differences from seq_read(): * . fixed buffer size (PAGE_SIZE) - * . assuming no_llseek + * . assuming NULL ->llseek() * . stop() may call bpf program, handling potential overflow there */ static ssize_t bpf_seq_read(struct file *file, char __user *buf, size_t size,