Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3281836iob; Mon, 16 May 2022 18:03:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLK8vDFaNJewDBCaCEtQR8EvQlZaL4m7YfjPB2FQ78SpZR9ZeTWoNCXk4zE/1w7XlZfN4i X-Received: by 2002:a17:907:a0ca:b0:6f8:5bef:b9c with SMTP id hw10-20020a170907a0ca00b006f85bef0b9cmr17627311ejc.630.1652749400729; Mon, 16 May 2022 18:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652749400; cv=none; d=google.com; s=arc-20160816; b=N/U5ta/nca4YIs94D/ZG6DqxFyil6ladgXkLjiuzqUPwMHQDed9y1xr9kfVy1y+JCF mN94FA6HAz1BR/QkqA5hrjdkVCp4Zg7Evtbrs4Qw5dX6KYwLPBsjh53UifdfyTfXyu8U E2LIcHhAModGlRhHZ0deOo3ggyNeOPNWvJ4gSzBW8oODfCaSB6rT1KWFXseCMJVyO02n z2PlGwJzt5XJxSuf8WL+hDwNm2jEzq8PRSKRrtDDi39E80MJlVxxBC3dWS94Rr3slNqH 135Oi5mu2073mIG6Sm8UCoLjmz69cvfNEtZziGL/BqwErVENfmu2BnJ/ahEOL8meYhFK E1LQ== 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=WUrJCpET5ioJAiVvwk8zHzwkwHsTKZgoemTPe72om30=; b=KvbNQUfVmSrUNtExT8P1BcGDyMzw7+tQozWWFvEnG46+GtbiEZD1wCqBoi3al9gm8v JgfVHNdqJ+2m8R3WnQ1LHxQDCTNyocqCJmWbCslqFaVWz8GmBRWeycl/WsFMvpKVFoWB uQdUCwXqf63cCrieoJ3mqw/94tdBIWt/kFh9P+GBooqizPQfR5TAV+QJkRn1/2DYW5jX b0S9hoI2saBwKeAk3FgblemXZvKgArLq3IFTluuHWHddwVNE1iEVr34Mqx0axBePD2WP VtljFnbZ4/b6feH16TabcKzyIeDgQixsHLu9lg3xPCkSzUNgVF6GUK5zip4y6Rg1+bmr rfoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fUttHnh4; 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 e22-20020a17090658d600b006e8c1be7b7asi1472898ejs.274.2022.05.16.18.02.55; Mon, 16 May 2022 18:03:20 -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=fUttHnh4; 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 S238176AbiEPUrx (ORCPT + 99 others); Mon, 16 May 2022 16:47:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244565AbiEPUpC (ORCPT ); Mon, 16 May 2022 16:45:02 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2DB7D483AA for ; Mon, 16 May 2022 13:22:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652732561; 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=WUrJCpET5ioJAiVvwk8zHzwkwHsTKZgoemTPe72om30=; b=fUttHnh4xG63oyrA6xXMNxjccF5iuBVqym5sBWSAO2gjmClV2bVXz4DGHx/mjXeC9pEgUv uLIDC7gEmV07DmzoP+4os/D/VFUlmD3zxooM+hcNf/6sPn0NL6XzFYOJXWAI4aOX5jncwX zeRzHh1odEUKBpRNaQ2tyO5kBTFDkuc= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-661-SJvpVGTBOBqR-JkPz4J76Q-1; Mon, 16 May 2022 16:22:38 -0400 X-MC-Unique: SJvpVGTBOBqR-JkPz4J76Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A4DA538149AA; Mon, 16 May 2022 20:22:37 +0000 (UTC) Received: from madcap2.tricolour.com (unknown [10.22.50.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B15840CF8E2; Mon, 16 May 2022 20:22:36 +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 v3 1/3] fanotify: Ensure consistent variable type for response Date: Mon, 16 May 2022 16:22:22 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 a3d5b751cac5..d66668e06bee 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 9b32b76a9c30..721e777ea90b 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 d06134ac6245..217784d602b3 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -419,7 +419,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, @@ -526,7 +526,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); @@ -686,7 +686,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 ea2ee1181921..6973be0bf6c9 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -2893,7 +2893,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