Re: [PATCH 064/190] Revert "nfc: s3fwrn5: replace the assertion with a WARN_ON"

From: Krzysztof Kozlowski
Date: Fri Apr 23 2021 - 03:30:02 EST


On 21/04/2021 14:58, Greg Kroah-Hartman wrote:
> This reverts commit 615f22f58029aa747b12768985e7f91cd053daa2.
>
> Commits from @umn.edu addresses have been found to be submitted in "bad
> faith" to try to test the kernel community's ability to review "known
> malicious" changes. The result of these submissions can be found in a
> paper published at the 42nd IEEE Symposium on Security and Privacy
> entitled, "Open Source Insecurity: Stealthily Introducing
> Vulnerabilities via Hypocrite Commits" written by Qiushi Wu (University
> of Minnesota) and Kangjie Lu (University of Minnesota).
>
> Because of this, all submissions from this group must be reverted from
> the kernel tree and will need to be re-reviewed again to determine if
> they actually are a valid fix. Until that work is complete, remove this
> change to ensure that no problems are being introduced into the
> codebase.
>
> Cc: Aditya Pakki <pakki001@xxxxxxx>
> Cc: David S. Miller <davem@xxxxxxxxxxxxx>
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> ---
> drivers/nfc/s3fwrn5/firmware.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/nfc/s3fwrn5/firmware.c b/drivers/nfc/s3fwrn5/firmware.c
> index eb5d7a5beac7..f77f183c9bd0 100644
> --- a/drivers/nfc/s3fwrn5/firmware.c
> +++ b/drivers/nfc/s3fwrn5/firmware.c
> @@ -492,10 +492,7 @@ int s3fwrn5_fw_recv_frame(struct nci_dev *ndev, struct sk_buff *skb)
> struct s3fwrn5_info *info = nci_get_drvdata(ndev);
> struct s3fwrn5_fw_info *fw_info = &info->fw_info;
>
> - if (WARN_ON(fw_info->rsp)) {
> - kfree_skb(skb);
> - return -EINVAL;
> - }
> + BUG_ON(fw_info->rsp);

It took me some time to understand this but the original commit looks
correct. The recv_frame functions s3fwrn5_recv_frame() or
nci_recv_frame() should free the skb buffer on errors. Here, the
s3fwrn5_fw_recv_frame() should be called only after sending a FW msg and
is expected to have fw_info->rsp=NULL. Otherwise it could mean that
frame came twice or it came when we did not ask for it.

Original code looks good, please drop the revert.

Best regards,
Krzysztof