Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2516201pxa; Mon, 17 Aug 2020 11:34:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhrgKSKuNjeSYie5KbZtbfJx1fVcM165gr5lkozPyIDb7JG0+DY0FRshEn1Wl0+K4uJ/P3 X-Received: by 2002:a50:e611:: with SMTP id y17mr15697654edm.376.1597689266419; Mon, 17 Aug 2020 11:34:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597689266; cv=none; d=google.com; s=arc-20160816; b=uPswiC+Tab21DGfk0BoMeu1hV4+f4vtTpHz5w9tC2/TryzqxluL9gLo9dfJEB2Nrzi Rg8H4IS6Ny32cqBTqvNdGWc2z9OWfokBUR+UfYr7KizeyIrs5+PqOgEJqx4Jm8Iklnb3 hH1tx7ucwOqEgtazb0oKzjsAWe1p2auDhOgZymrslpmy8O8DlcnYH+breIYtDaQBSX4V vfdN6sWY3jpuZoHFbUhNykHEwd0egMY7CDlhRAb2S9yN76BsxekCYOPhDP2mf63EGhHx Ih7QIWgZUQYah4DOfvV7fTskrfcQkUQHpqf+biwMwSiLpA8ZuJAi+2dSvZe/s83rFXO5 IQ4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=L4RJfFv0g5h3mTqpiMrw6vgOTmZGA8UWnjGX6u61QsA=; b=mMiMBzig0gLVjf3tmB7WnCpQgym18eWkZmRDUhhiUe5zfF8CLc0ynPKaiUGwvtu1kS 3SVQnqcTiv1xhy4OiVPmgTTbMA0XZzVJ9CrOMsvZAPZdRm9WDmimzJsavZRgUz4uwvVX J8WYmMEK+jF/dbO0xjZB2FyMzvKmGsV6yRNFdRV8EbApJmPXhW2/bw5Y//45paGP6SX5 uJvsOqLDnuWxz5REcQfMEvsuTrUvozQtv9e+iSDWWAvaO3/E5cZ4k2gjhgGEqgeuuPKE TF6Tk4elAZutGzVSvbH9ZNYmatZrAtFtZHNIMFw4GK+en/MIU3jEq38BuAP5kQi0fNTY YvvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=w3sSuv0L; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j30si12081024ejo.753.2020.08.17.11.34.03; Mon, 17 Aug 2020 11:34:26 -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=@kernel.org header.s=default header.b=w3sSuv0L; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390976AbgHQSbn (ORCPT + 99 others); Mon, 17 Aug 2020 14:31:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:48562 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387941AbgHQQBI (ORCPT ); Mon, 17 Aug 2020 12:01:08 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9987C207FB; Mon, 17 Aug 2020 16:01:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680067; bh=cjtdBc3RixVqwCdUJQihsAUyE8l5VSflaCE6otsLWuA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w3sSuv0LLn14wvg4LQIL0xKvFLI56Q8TawdwJMUlxR00X2DIkzvGN+li1M77YKlsQ 2cGfd/MxDSGGTHSOg7p29tRJf95F+slZZnP1WJKE5hQRXoaW+9rMY8npy/PDuIEycF 2oFKWldLm9CwyPElZZioNDaFYAZhfOxRjqkPQhwQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kees Cook , Sasha Levin Subject: [PATCH 5.4 040/270] seccomp: Fix ioctl number for SECCOMP_IOCTL_NOTIF_ID_VALID Date: Mon, 17 Aug 2020 17:14:01 +0200 Message-Id: <20200817143757.801486980@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143755.807583758@linuxfoundation.org> References: <20200817143755.807583758@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kees Cook [ Upstream commit 47e33c05f9f07cac3de833e531bcac9ae052c7ca ] When SECCOMP_IOCTL_NOTIF_ID_VALID was first introduced it had the wrong direction flag set. While this isn't a big deal as nothing currently enforces these bits in the kernel, it should be defined correctly. Fix the define and provide support for the old command until it is no longer needed for backward compatibility. Fixes: 6a21cc50f0c7 ("seccomp: add a return code to trap to userspace") Signed-off-by: Kees Cook Signed-off-by: Sasha Levin --- include/uapi/linux/seccomp.h | 3 ++- kernel/seccomp.c | 9 +++++++++ tools/testing/selftests/seccomp/seccomp_bpf.c | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/seccomp.h b/include/uapi/linux/seccomp.h index 90734aa5aa363..b5f901af79f0b 100644 --- a/include/uapi/linux/seccomp.h +++ b/include/uapi/linux/seccomp.h @@ -93,5 +93,6 @@ struct seccomp_notif_resp { #define SECCOMP_IOCTL_NOTIF_RECV SECCOMP_IOWR(0, struct seccomp_notif) #define SECCOMP_IOCTL_NOTIF_SEND SECCOMP_IOWR(1, \ struct seccomp_notif_resp) -#define SECCOMP_IOCTL_NOTIF_ID_VALID SECCOMP_IOR(2, __u64) +#define SECCOMP_IOCTL_NOTIF_ID_VALID SECCOMP_IOW(2, __u64) + #endif /* _UAPI_LINUX_SECCOMP_H */ diff --git a/kernel/seccomp.c b/kernel/seccomp.c index 2c697ce7be21f..e0fd972356539 100644 --- a/kernel/seccomp.c +++ b/kernel/seccomp.c @@ -42,6 +42,14 @@ #include #include +/* + * When SECCOMP_IOCTL_NOTIF_ID_VALID was first introduced, it had the + * wrong direction flag in the ioctl number. This is the broken one, + * which the kernel needs to keep supporting until all userspaces stop + * using the wrong command number. + */ +#define SECCOMP_IOCTL_NOTIF_ID_VALID_WRONG_DIR SECCOMP_IOR(2, __u64) + enum notify_state { SECCOMP_NOTIFY_INIT, SECCOMP_NOTIFY_SENT, @@ -1168,6 +1176,7 @@ static long seccomp_notify_ioctl(struct file *file, unsigned int cmd, return seccomp_notify_recv(filter, buf); case SECCOMP_IOCTL_NOTIF_SEND: return seccomp_notify_send(filter, buf); + case SECCOMP_IOCTL_NOTIF_ID_VALID_WRONG_DIR: case SECCOMP_IOCTL_NOTIF_ID_VALID: return seccomp_notify_id_valid(filter, buf); default: diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index 96bbda4f10fc6..19c7351eeb74b 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c @@ -177,7 +177,7 @@ struct seccomp_metadata { #define SECCOMP_IOCTL_NOTIF_RECV SECCOMP_IOWR(0, struct seccomp_notif) #define SECCOMP_IOCTL_NOTIF_SEND SECCOMP_IOWR(1, \ struct seccomp_notif_resp) -#define SECCOMP_IOCTL_NOTIF_ID_VALID SECCOMP_IOR(2, __u64) +#define SECCOMP_IOCTL_NOTIF_ID_VALID SECCOMP_IOW(2, __u64) struct seccomp_notif { __u64 id; -- 2.25.1