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 X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03572C433E3 for ; Thu, 20 Aug 2020 00:07:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC0F7207FB for ; Thu, 20 Aug 2020 00:07:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597882030; bh=xAbJ9aQ6MAPazak0G1KJ0FiE6uz5m2Kr0/xkdHt9jSI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=hoiCXBDeKvUIXIYqCF+ASJKrVfaiDBJdDk5kICgACHZyRzRSBTCCCoGlHnTC2WGUe 1TEx+eRKuRD8S9S1KP0UoLWXVTRbThUfjqWI3rhbli2zDHV84mSEc+jvuRabvdQYcA q3+STItOrzJmyRGjMQyf6hi4apDvYGLQyrDfVfFk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728266AbgHTAHJ (ORCPT ); Wed, 19 Aug 2020 20:07:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:33130 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728281AbgHTAD1 (ORCPT ); Wed, 19 Aug 2020 20:03:27 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 87112207FB; Thu, 20 Aug 2020 00:03:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597881807; bh=xAbJ9aQ6MAPazak0G1KJ0FiE6uz5m2Kr0/xkdHt9jSI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tqpS+NHG1kWpn5Q3R4bgt12LpfuqoX47pljRZrapp0ronIV+0bIplq2+EmTckzLa8 /NZ9jwZ8QPOI6Li0iwoFbcqKdNwqDFKa/jLYRySngWWID3dWZD8RjiWrxvjlYBfpU0 XgFaM552kCFDAaQR5bWBz0ElIB3STNSI8NwOkuPU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Helge Deller , Andrew Morton , Alexander Viro , Laurent Vivier , Linus Torvalds , Sasha Levin , linux-fsdevel@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 18/18] fs/signalfd.c: fix inconsistent return codes for signalfd4 Date: Wed, 19 Aug 2020 20:03:01 -0400 Message-Id: <20200820000302.215560-18-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200820000302.215560-1-sashal@kernel.org> References: <20200820000302.215560-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Helge Deller [ Upstream commit a089e3fd5a82aea20f3d9ec4caa5f4c65cc2cfcc ] The kernel signalfd4() syscall returns different error codes when called either in compat or native mode. This behaviour makes correct emulation in qemu and testing programs like LTP more complicated. Fix the code to always return -in both modes- EFAULT for unaccessible user memory, and EINVAL when called with an invalid signal mask. Signed-off-by: Helge Deller Signed-off-by: Andrew Morton Cc: Alexander Viro Cc: Laurent Vivier Link: http://lkml.kernel.org/r/20200530100707.GA10159@ls3530.fritz.box Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/signalfd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/signalfd.c b/fs/signalfd.c index 4fcd1498acf52..3c40a3bf772ce 100644 --- a/fs/signalfd.c +++ b/fs/signalfd.c @@ -313,9 +313,10 @@ SYSCALL_DEFINE4(signalfd4, int, ufd, sigset_t __user *, user_mask, { sigset_t mask; - if (sizemask != sizeof(sigset_t) || - copy_from_user(&mask, user_mask, sizeof(mask))) + if (sizemask != sizeof(sigset_t)) return -EINVAL; + if (copy_from_user(&mask, user_mask, sizeof(mask))) + return -EFAULT; return do_signalfd4(ufd, &mask, flags); } @@ -324,9 +325,10 @@ SYSCALL_DEFINE3(signalfd, int, ufd, sigset_t __user *, user_mask, { sigset_t mask; - if (sizemask != sizeof(sigset_t) || - copy_from_user(&mask, user_mask, sizeof(mask))) + if (sizemask != sizeof(sigset_t)) return -EINVAL; + if (copy_from_user(&mask, user_mask, sizeof(mask))) + return -EFAULT; return do_signalfd4(ufd, &mask, 0); } -- 2.25.1