From patchwork Mon May 11 18:02:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabian Frederick X-Patchwork-Id: 11541403 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 950B1913 for ; Mon, 11 May 2020 18:02:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 81C1920720 for ; Mon, 11 May 2020 18:02:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729635AbgEKSCf (ORCPT ); Mon, 11 May 2020 14:02:35 -0400 Received: from mailrelay107.isp.belgacom.be ([195.238.20.134]:58610 "EHLO mailrelay107.isp.belgacom.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726891AbgEKSCe (ORCPT ); Mon, 11 May 2020 14:02:34 -0400 IronPort-SDR: rxp6Kn8uyDJ/BhICncl+TvFI3dOyE/RusIYuDHVw45Pa9xbWxGKlPoaqjIIVMeJgNy+3djqyyb MPSOFUbbU16ilEHxf6SG/d1UHZZ4qWqpK16ermUjExGJRNFl2/uGU+77Oogbt/u4SWkySrcU4s eKCSugjcuK1gOxr1zDywT3kPQt/mEcdPC7Oxbc9M6fhHfEjMR3KB9CJxtHg8XMKNmNt0iVcfWc d8I9HWfpUh+IBXq15yl38nVyDr2fHFgEMR+Yarnqb6ruXus8t54J0WjtfO3pWIPCkuZi4kh4l6 Vq0= X-Belgacom-Dynamic: yes IronPort-PHdr: 9a23:pui0rh18VPP31ifIsmDT+DRfVm0co7zxezQtwd8ZseMSIvad9pjvdHbS+e9qxAeQG9mCtrQV06GP6vqocFdDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXdrXKo8DEdBAj0OxZrKeTpAI7SiNm82/yv95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BN+rV2JiBuktysMDNh4uU+6piQrOinKn X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CoBAACkrle/xCltltmglCCKoFkEiyNJYV6jBiPXYF7CwEBAQEBAQEBATQBAgQBAYREgg0nNAkOAgMBAQEDAgUBAQYBAQEBAQEEBAFsBAEBBwoCAYROIQEDAQEFCgFDgjsig0ILASMjT3ASgyaCWCmwQTOFUYNWgUCBOIddhQGBQT+EX4pCBLJrglSCcZUrDB2dOpAdnyQ5gVZNIBiDJFAYDZ8KQjA3AgYIAQEDCVcBIgGOCAEB X-IPAS-Result: A2CoBAACkrle/xCltltmglCCKoFkEiyNJYV6jBiPXYF7CwEBAQEBAQEBATQBAgQBAYREgg0nNAkOAgMBAQEDAgUBAQYBAQEBAQEEBAFsBAEBBwoCAYROIQEDAQEFCgFDgjsig0ILASMjT3ASgyaCWCmwQTOFUYNWgUCBOIddhQGBQT+EX4pCBLJrglSCcZUrDB2dOpAdnyQ5gVZNIBiDJFAYDZ8KQjA3AgYIAQEDCVcBIgGOCAEB Received: from 16.165-182-91.adsl-dyn.isp.belgacom.be (HELO biggussolus.home) ([91.182.165.16]) by relay.skynet.be with ESMTP; 11 May 2020 20:02:31 +0200 From: Fabian Frederick To: jack@suse.cz, amir73il@gmail.com Cc: linux-fsdevel@vger.kernel.org, Fabian Frederick Subject: [PATCH 7/9 linux-next] fanotify: don't write with zero size Date: Mon, 11 May 2020 20:02:27 +0200 Message-Id: <20200511180227.215152-1-fabf@skynet.be> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org check count in fanotify_write() and return -EINVAL when 0 Signed-off-by: Fabian Frederick --- fs/notify/fanotify/fanotify_user.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 02a314acc757..6e19dacb2475 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -485,6 +485,9 @@ static ssize_t fanotify_write(struct file *file, const char __user *buf, size_t if (!IS_ENABLED(CONFIG_FANOTIFY_ACCESS_PERMISSIONS)) return -EINVAL; + if (!count) + return -EINVAL; + group = file->private_data; if (count > sizeof(response))