Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6193737rwb; Tue, 9 Aug 2022 10:38:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Df5FVGebsuaitfF2Alpz9wDd/oMpK+YCyG7XJwuCl589MdJ+llhCBa0jGJyuu/v4VI+lK X-Received: by 2002:a17:903:11d0:b0:171:2cbc:3d06 with SMTP id q16-20020a17090311d000b001712cbc3d06mr1776217plh.142.1660066703927; Tue, 09 Aug 2022 10:38:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660066703; cv=none; d=google.com; s=arc-20160816; b=EzRRuktiD4zwoHtbNjzpucaP9ZOGpGZxuoJTAU1y2DsBiU1NP5NwIVdOF/1fjyTTe5 hhpd67fyV8Wy2OurWpSXY4usa/Nmt7XqjBJ3B+PgXrLR4deIQdP0XJifn4ni69iwA8vS w5elFUXKzRAwWdLyO5toLjAPfBmXSYFjJtXzKt1Qw3qePt2s6a/6Ax4DaoYKmbwMQH5h ZSpd2p1GSLmS/s1FXJd8VjztUZcimJcJU3hgZePZLi0yEsyas9jXf1/Sx9iqWUjnbIrt 7+rfaaKr2irSzADvHWMsghatVaI2i2+siV9eNWle0ENwR0QztA5XuvaCQoKzpU1C/28t 6QyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=u1KS97z9xRvQFlp9o7uta5H/iq3B/8fcs7J3SYSbtRw=; b=wV4IqMTiT0MWz0iUqYFGx8/xldJYfg736yO0XA7KrFVfp+bKl4hCpy35YJ4OzgVe9f aqCHWQh4Ds0WXsE+POc34Nxbd/xJom2z0e0IDp4g7fHoXjFw15zqlhPslB1BkSPX46sa ZGayyJfZdEI7XjIkmO2HEJoHy+JkSvOnukbFjCrf3aEk02HA9hRk5OdpCYhUPj4DRFO+ g6eRE+mvqsEMiV0VDtSPNnJiuIzE4HyxvtVAQagOQWrmSfqWkQNiVTdtDXR5aiHv3tCw yC4q3Ba/V1jA2r0aUMVvEzHV6DtBPcikyP8l7jr9cc+ElyPb8bG8Hph5/iqjq4TfB8nA aVKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XZcrKbPb; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d9-20020a170902cec900b0016eec129304si9309397plg.259.2022.08.09.10.37.59; Tue, 09 Aug 2022 10:38:23 -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=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XZcrKbPb; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245201AbiHIRX0 (ORCPT + 99 others); Tue, 9 Aug 2022 13:23:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242624AbiHIRXV (ORCPT ); Tue, 9 Aug 2022 13:23:21 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 636182529E for ; Tue, 9 Aug 2022 10:23:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660065796; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u1KS97z9xRvQFlp9o7uta5H/iq3B/8fcs7J3SYSbtRw=; b=XZcrKbPbrZEcIQ87w99fDjcRdp3tgwwmPfz6mNelozvgUdJdYcJ11xfWE1xd5kPSukDrqw PNM7JqlAvG1wDVYMCmT9n6Z+Kfszo3ENAGRIQjRu8tRo1PlY33iKY+q5950NDhaVgslEys DR8TN5jHZ8bNjhyse3MBAjyRDFmCaeQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-246-1LJF1l9JOOaMAnlCsoxtVw-1; Tue, 09 Aug 2022 13:23:13 -0400 X-MC-Unique: 1LJF1l9JOOaMAnlCsoxtVw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 85BFD976065; Tue, 9 Aug 2022 17:23:12 +0000 (UTC) Received: from madcap2.tricolour.com (unknown [10.22.48.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46CBF94585; Tue, 9 Aug 2022 17:23:11 +0000 (UTC) From: Richard Guy Briggs To: Linux-Audit Mailing List , LKML , linux-fsdevel@vger.kernel.org Cc: Paul Moore , Eric Paris , Steve Grubb , Richard Guy Briggs , Jan Kara , Amir Goldstein Subject: [PATCH v4 1/4] fanotify: Ensure consistent variable type for response Date: Tue, 9 Aug 2022 13:22:52 -0400 Message-Id: <42afb21b7b6adeee70293116e603bd4bc4a8f9a3.1659996830.git.rgb@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The user space API for the response variable is __u32. This patch makes sure that the whole path through the kernel uses u32 so that there is no sign extension or truncation of the user space response. Suggested-by: Steve Grubb Link: https://lore.kernel.org/r/12617626.uLZWGnKmhe@x2 Signed-off-by: Richard Guy Briggs --- fs/notify/fanotify/fanotify.h | 2 +- fs/notify/fanotify/fanotify_user.c | 6 +++--- include/linux/audit.h | 6 +++--- kernel/auditsc.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/notify/fanotify/fanotify.h b/fs/notify/fanotify/fanotify.h index 80e0ec95b113..abfa3712c185 100644 --- a/fs/notify/fanotify/fanotify.h +++ b/fs/notify/fanotify/fanotify.h @@ -425,7 +425,7 @@ FANOTIFY_PE(struct fanotify_event *event) struct fanotify_perm_event { struct fanotify_event fae; struct path path; - unsigned short response; /* userspace answer to the event */ + u32 response; /* userspace answer to the event */ unsigned short state; /* state of the event */ int fd; /* fd we passed to userspace for this event */ }; diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index c2255b440df9..ff67ca0d25cc 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -289,7 +289,7 @@ static int create_fd(struct fsnotify_group *group, struct path *path, */ static void finish_permission_event(struct fsnotify_group *group, struct fanotify_perm_event *event, - unsigned int response) + u32 response) __releases(&group->notification_lock) { bool destroy = false; @@ -310,9 +310,9 @@ static int process_access_response(struct fsnotify_group *group, { struct fanotify_perm_event *event; int fd = response_struct->fd; - int response = response_struct->response; + u32 response = response_struct->response; - pr_debug("%s: group=%p fd=%d response=%d\n", __func__, group, + pr_debug("%s: group=%p fd=%d response=%u\n", __func__, group, fd, response); /* * make sure the response is valid, if invalid we do nothing and either diff --git a/include/linux/audit.h b/include/linux/audit.h index 00f7a80f1a3e..3ea198a2cd59 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -417,7 +417,7 @@ extern void __audit_log_capset(const struct cred *new, const struct cred *old); extern void __audit_mmap_fd(int fd, int flags); extern void __audit_openat2_how(struct open_how *how); extern void __audit_log_kern_module(char *name); -extern void __audit_fanotify(unsigned int response); +extern void __audit_fanotify(u32 response); extern void __audit_tk_injoffset(struct timespec64 offset); extern void __audit_ntp_log(const struct audit_ntp_data *ad); extern void __audit_log_nfcfg(const char *name, u8 af, unsigned int nentries, @@ -524,7 +524,7 @@ static inline void audit_log_kern_module(char *name) __audit_log_kern_module(name); } -static inline void audit_fanotify(unsigned int response) +static inline void audit_fanotify(u32 response) { if (!audit_dummy_context()) __audit_fanotify(response); @@ -684,7 +684,7 @@ static inline void audit_log_kern_module(char *name) { } -static inline void audit_fanotify(unsigned int response) +static inline void audit_fanotify(u32 response) { } static inline void audit_tk_injoffset(struct timespec64 offset) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index f3a2abd6d1a1..433418d73584 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -2899,7 +2899,7 @@ void __audit_log_kern_module(char *name) context->type = AUDIT_KERN_MODULE; } -void __audit_fanotify(unsigned int response) +void __audit_fanotify(u32 response) { audit_log(audit_context(), GFP_KERNEL, AUDIT_FANOTIFY, "resp=%u", response); -- 2.27.0